ZQuest Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2025-08-24 12:35:46
Exec Total Coverage
Lines: 9208 12213 75.4%
Functions: 378 436 86.7%
Branches: 7299 12917 56.5%

Line Branch Exec Source
1 #include "base/handles.h"
2 #include "base/zdefs.h"
3 #include <cstring>
4 #include <optional>
5 #include <stdio.h>
6 #include "base/combo.h"
7 #include "base/general.h"
8 #include "base/zc_alleg.h"
9 #include "zc/guys.h"
10 #include "zc/replay.h"
11 #include "zc/zc_ffc.h"
12 #include "zc/zc_subscr.h"
13 #include "zc/zelda.h"
14 #include "base/zsys.h"
15 #include "base/msgstr.h"
16 #include "zc/maps.h"
17 #include "zc/hero.h"
18 #include "subscr.h"
19 #include "zc/ffscript.h"
20 #include "gamedata.h"
21 #include "defdata.h"
22 #include "zscriptversion.h"
23 #include "particles.h"
24 #include "base/zc_math.h"
25 #include "slopes.h"
26 #include "base/qrs.h"
27 #include "base/dmap.h"
28 #include "base/mapscr.h"
29 #include "base/misctypes.h"
30 #include "base/initdata.h"
31 #include "zc/combos.h"
32 #include "iter.h"
33
34 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
35
36 int32_t repaircharge=0;
37 bool adjustmagic=false;
38 bool learnslash=false;
39 int32_t wallm_load_clk=0;
40 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
41 int32_t vhead=0;
42
43 char *guy_string[eMAXGUYS];
44
45 void playLevelMusic();
46
47 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
48 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
49
50 1113385 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
51 {
52 1113385 int32_t c = coord.getInt();
53
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 1113108 times.
1113385 if(nearest_half)
54 {
55
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1113108 times.
1113108 if (c < 0)
56 c -= val / 2;
57 1113108 else c += (val/2);
58 1113108 }
59 1113385 c -= c % val;
60 1113385 coord = c;
61 1113385 }
62
63 38564049 static bool OUTOFBOUNDS(int32_t id, int32_t x, int32_t y)
64 {
65
4/4
✓ Branch 0 taken 38047443 times.
✓ Branch 1 taken 516606 times.
✓ Branch 2 taken 1215 times.
✓ Branch 3 taken 38562834 times.
38564049 if (y > world_h + (isSideViewGravity() && canfall(id) ? 16 : 176)) return true;
66
2/2
✓ Branch 0 taken 30320 times.
✓ Branch 1 taken 38532514 times.
38562834 if (y < -176) return true;
67
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38532514 times.
38532514 if (x < -256) return true;
68
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 38532448 times.
38532514 if (x > world_w+256) return true;
69 38532448 return false;
70 38564049 }
71
72 bool NEWOUTOFBOUNDS(int32_t x, int32_t y, int32_t z)
73 {
74 return
75 (
76 (y > FFCore.enemy_removal_point[spriteremovalY2])
77 || (y < FFCore.enemy_removal_point[spriteremovalY1])
78 || (x < FFCore.enemy_removal_point[spriteremovalX1])
79 || (x > FFCore.enemy_removal_point[spriteremovalX2])
80 || (z < FFCore.enemy_removal_point[spriteremovalZ1])
81 || (z > FFCore.enemy_removal_point[spriteremovalZ2])
82 );
83 }
84
85 6674 static void position_relative_to_screen(zfix& x, zfix& y, int32_t rx, int32_t ry)
86 {
87 6674 x = rx + (x.getInt()/256)*256;
88 6674 y = ry + (y.getInt()/176)*176;
89 6674 }
90
91 namespace
92 {
93 int32_t trapConstantHorizontalID;
94 int32_t trapConstantVerticalID;
95 int32_t trapLOSHorizontalID;
96 int32_t trapLOSVerticalID;
97 int32_t trapLOS4WayID;
98
99 int32_t cornerTrapID;
100 int32_t centerTrapID;
101
102 int32_t rockID;
103 int32_t zoraID;
104 int32_t statueID;
105 }
106
107 422 void identifyCFEnemies()
108 {
109 422 trapConstantHorizontalID=-1;
110 422 trapConstantVerticalID=-1;
111 422 trapLOSHorizontalID=-1;
112 422 trapLOSVerticalID=-1;
113 422 trapLOS4WayID=-1;
114 422 cornerTrapID=-1;
115 422 centerTrapID=-1;
116 422 rockID=-1;
117 422 zoraID=-1;
118 422 statueID=-1;
119
120
2/2
✓ Branch 0 taken 216064 times.
✓ Branch 1 taken 422 times.
216486 for(int32_t i=0; i<eMAXGUYS; i++)
121 {
122
3/4
✓ Branch 0 taken 417 times.
✓ Branch 1 taken 215647 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 417 times.
216064 if((guysbuf[i].flags&guy_trph) && trapLOSHorizontalID==-1)
123 417 trapLOSHorizontalID=i;
124
4/4
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 215636 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags&guy_trpv) && trapLOSVerticalID==-1)
125 422 trapLOSVerticalID=i;
126
3/4
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 215642 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags&guy_trp4) && trapLOS4WayID==-1)
127 422 trapLOS4WayID=i;
128
3/4
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 215642 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags&guy_trplr) && trapConstantHorizontalID==-1)
129 422 trapConstantHorizontalID=i;
130
3/4
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 215642 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags&guy_trpud) && trapConstantVerticalID==-1)
131 422 trapConstantVerticalID=i;
132
133
3/4
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 215642 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags&guy_trap) && cornerTrapID==-1)
134 422 cornerTrapID=i;
135
3/4
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 215642 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags&guy_trp2) && centerTrapID==-1)
136 422 centerTrapID=i;
137
138
3/4
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 215642 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags&guy_rock) && rockID==-1)
139 422 rockID=i;
140
4/4
✓ Branch 0 taken 445 times.
✓ Branch 1 taken 215619 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 419 times.
216064 if((guysbuf[i].flags&guy_zora) && zoraID==-1)
141 419 zoraID=i;
142
143
4/4
✓ Branch 0 taken 485 times.
✓ Branch 1 taken 215579 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 422 times.
216064 if((guysbuf[i].flags & guy_fire) && statueID==-1)
144 422 statueID=i;
145 216064 }
146 422 }
147
148 32 int32_t random_layer_enemy(int screen)
149 {
150 32 int32_t cnt=count_layer_enemies(screen);
151 32 mapscr* base_scr = get_scr(screen);
152
153
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(cnt==0)
154 {
155 return eNONE;
156 }
157
158 32 int32_t ret=zc_oldrand()%cnt;
159 32 cnt=0;
160
161
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 for(int32_t i=0; i<6; ++i)
162 {
163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(base_scr->layermap[i]!=0)
164 {
165 32 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
166
167
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 for(int32_t j=0; j<10; ++j)
168 {
169
2/4
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140 times.
140 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
170 {
171
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 108 times.
140 if(cnt==ret)
172 {
173 32 return layerscreen->enemy[j];
174 }
175
176 108 ++cnt;
177 108 }
178 108 }
179 }
180 }
181
182 return eNONE;
183 32 }
184
185 49 int32_t count_layer_enemies(int screen)
186 {
187 49 int32_t cnt=0;
188
189 49 mapscr* base_scr = get_scr(screen);
190
191
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 49 times.
343 for(int32_t i=0; i<6; ++i)
192 {
193
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 79 times.
294 if (base_scr->layermap[i])
194 {
195 79 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
196
197
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 79 times.
869 for(int32_t j=0; j<10; ++j)
198 {
199
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 420 times.
790 if(layerscreen->enemy[j]!=0)
200 {
201 420 ++cnt;
202 420 }
203 790 }
204 79 }
205 294 }
206
207 49 return cnt;
208 }
209
210 211789 int32_t hero_on_wall()
211 {
212 211789 zfix lx = Hero.getX();
213 211789 zfix ly = Hero.getY();
214
215
4/4
✓ Branch 0 taken 189837 times.
✓ Branch 1 taken 21952 times.
✓ Branch 2 taken 8850 times.
✓ Branch 3 taken 180987 times.
211789 if(lx>=48 && lx<=world_w-64)
216 {
217
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 180756 times.
180987 if(ly==32) return up+1;
218
219
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 180473 times.
180756 if(ly==world_h-48) return down+1;
220 180473 }
221
222
4/4
✓ Branch 0 taken 194033 times.
✓ Branch 1 taken 17242 times.
✓ Branch 2 taken 21403 times.
✓ Branch 3 taken 172630 times.
211275 if(ly>=48 && ly<=world_h-64)
223 {
224
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 172407 times.
172630 if(lx==32) return left+1;
225
226
2/2
✓ Branch 0 taken 172303 times.
✓ Branch 1 taken 104 times.
172407 if(lx==world_w-48) return right+1;
227 172303 }
228
229 210948 return 0;
230 211789 }
231
232 806969 bool tooclose(int32_t x,int32_t y,int32_t d)
233 {
234
2/2
✓ Branch 0 taken 600909 times.
✓ Branch 1 taken 206060 times.
806969 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
235 }
236
237 4019514 bool enemy::overpit(enemy *e)
238 {
239 // This function (and shadow_overpit) has been broken since it was written, and only
240 // checked the same diagonal of the hitbox, over and over again. The bug is because both
241 // loops used the same variable name.
242 // Checking literally every pixel seems like overkill, so for now let's continue to
243 // do the single diagonal but just once. That's why the outer loop is commented out.
244
245 // for ( int32_t q = 0; q < hxsz; ++q )
246 {
247
2/2
✓ Branch 0 taken 37189774 times.
✓ Branch 1 taken 4000312 times.
41190086 for ( int32_t q = 0; q < hit_height; ++q )
248 {
249 //check every pixel of the hitbox
250
2/2
✓ Branch 0 taken 19202 times.
✓ Branch 1 taken 37170572 times.
37189774 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
251 {
252 //if the hitbox is over a pit, we can't land
253 19202 return true;
254 }
255 37170572 }
256 }
257 4000312 return false;
258 4019514 }
259
260 12361841 bool enemy::shadow_overpit(enemy *e)
261 {
262 // for ( int32_t q = 0; q < hxsz; ++q )
263 {
264
2/2
✓ Branch 0 taken 177577154 times.
✓ Branch 1 taken 12335380 times.
189912534 for ( int32_t q = 0; q < hit_height; ++q )
265 {
266 //check every pixel of the hitbox
267
2/2
✓ Branch 0 taken 26461 times.
✓ Branch 1 taken 177550693 times.
177577154 if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) )
268 {
269 //if the hitbox is over a pit, we can't land
270 26461 return true;
271 }
272 177550693 }
273 }
274 12335380 return false;
275 12361841 }
276
277 // Returns true iff a combo type or flag precludes enemy movement.
278 7438667 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
279 {
280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7438667 times.
7438667 if(moveflags & move_ignore_blockflags) return false;
281 7438667 int32_t c = COMBOTYPE(dx,dy);
282
4/4
✓ Branch 0 taken 4895519 times.
✓ Branch 1 taken 2543148 times.
✓ Branch 2 taken 1400387 times.
✓ Branch 3 taken 1142761 times.
9981815 bool pit_blocks = (!(moveflags & (move_can_pitwalk|move_only_pitwalk)) && (!(moveflags & move_can_pitfall) || !isKB));
283
3/6
✓ Branch 0 taken 2524824 times.
✓ Branch 1 taken 4913843 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2524824 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7438667 bool water_blocks = (!(moveflags & (move_can_waterwalk|move_only_waterwalk|move_only_shallow_waterwalk)) && (!(moveflags & move_can_waterdrown) || !isKB) && get_qr(qr_DROWN));
284
5/6
✓ Branch 0 taken 2584370 times.
✓ Branch 1 taken 4854297 times.
✓ Branch 2 taken 2582493 times.
✓ Branch 3 taken 1877 times.
✓ Branch 4 taken 2582493 times.
✗ Branch 5 not taken.
14878098 return c==cPIT || c==cPITB || c==cPITC ||
285
4/6
✓ Branch 0 taken 2582493 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2582493 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2433745 times.
✓ Branch 5 taken 148748 times.
2582493 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
286 // Block enemies type and block enemies flags
287
2/2
✓ Branch 0 taken 2577217 times.
✓ Branch 1 taken 2428469 times.
148748 combo_class_buf[c].block_enemies&1 ||
288
4/4
✓ Branch 0 taken 2574547 times.
✓ Branch 1 taken 2670 times.
✓ Branch 2 taken 2574300 times.
✓ Branch 3 taken 247 times.
2577217 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
289
4/4
✓ Branch 0 taken 2573482 times.
✓ Branch 1 taken 818 times.
✓ Branch 2 taken 2573416 times.
✓ Branch 3 taken 66 times.
2574300 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
290 // Check for ladder-only combos which aren't dried water
291
4/4
✓ Branch 0 taken 10626 times.
✓ Branch 1 taken 2562790 times.
✓ Branch 2 taken 10331 times.
✓ Branch 3 taken 295 times.
5146537 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
292 // Check for drownable water
293
4/4
✓ Branch 0 taken 574658 times.
✓ Branch 1 taken 1998463 times.
✓ Branch 2 taken 2332 times.
✓ Branch 3 taken 572326 times.
2573121 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true, false, false)));
294 2587011 }
295
296 // Returns true iff enemy is floating and blocked by a combo type or flag.
297 8696119 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
298 {
299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8696119 times.
8696119 if(moveflags & move_ignore_blockflags) return false;
300
4/4
✓ Branch 0 taken 6597137 times.
✓ Branch 1 taken 2098982 times.
✓ Branch 2 taken 1750204 times.
✓ Branch 3 taken 348778 times.
10795101 bool pit_blocks = (!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !isKB));
301
3/4
✓ Branch 0 taken 6611644 times.
✓ Branch 1 taken 2084475 times.
✓ Branch 2 taken 2084475 times.
✗ Branch 3 not taken.
10780594 bool water_blocks = (!(moveflags & move_can_waterwalk) && (!(moveflags & move_can_waterdrown) || !isKB));
302
2/2
✓ Branch 0 taken 1202011 times.
✓ Branch 1 taken 7494108 times.
16190227 return ((special==spw_floater)&&
303
2/2
✓ Branch 0 taken 7483965 times.
✓ Branch 1 taken 10143 times.
7494108 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
304
2/2
✓ Branch 0 taken 7483846 times.
✓ Branch 1 taken 119 times.
7483965 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
305
2/2
✓ Branch 0 taken 7483675 times.
✓ Branch 1 taken 171 times.
7483846 (MAPFLAG(dx,dy)==mfNOENEMY)||
306
2/2
✓ Branch 0 taken 7483420 times.
✓ Branch 1 taken 255 times.
7483675 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
307
4/4
✓ Branch 0 taken 1242529 times.
✓ Branch 1 taken 6240891 times.
✓ Branch 2 taken 4004 times.
✓ Branch 3 taken 1238525 times.
14962836 (water_blocks && iswaterex_z3(MAPCOMBO(dx, dy), -1, dx,dy, false, false, true)) ||
308
2/2
✓ Branch 0 taken 6231302 times.
✓ Branch 1 taken 1248114 times.
7479416 (pit_blocks && ispitfall(dx,dy))));
309 8696119 }
310 // Returns true iff a combo type or flag precludes enemy movement.
311 282052 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
312 {
313 282052 int32_t c = COMBOTYPE(dx,dy);
314 282052 bool pit_blocks = !(gd.moveflags & move_can_pitwalk);
315
2/2
✓ Branch 0 taken 35554 times.
✓ Branch 1 taken 246498 times.
282052 bool water_blocks = !(gd.moveflags & move_can_waterwalk) && get_qr(qr_DROWN);
316
5/6
✓ Branch 0 taken 282032 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 281915 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 281915 times.
✗ Branch 5 not taken.
1062905 return c==cPIT || c==cPITB || c==cPITC ||
317
4/6
✓ Branch 0 taken 281915 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 281915 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 250042 times.
✓ Branch 5 taken 31873 times.
281915 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
318 // Block enemies type and block enemies flags
319
2/2
✓ Branch 0 taken 281342 times.
✓ Branch 1 taken 249469 times.
31873 combo_class_buf[c].block_enemies&1 ||
320
4/4
✓ Branch 0 taken 280955 times.
✓ Branch 1 taken 387 times.
✓ Branch 2 taken 280924 times.
✓ Branch 3 taken 31 times.
281342 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
321
4/4
✓ Branch 0 taken 277269 times.
✓ Branch 1 taken 3655 times.
✓ Branch 2 taken 276994 times.
✓ Branch 3 taken 275 times.
280924 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
322 // Check for ladder-only combos which aren't dried water
323
4/4
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 275950 times.
✓ Branch 2 taken 1005 times.
✓ Branch 3 taken 39 times.
553949 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
324 // Check for drownable water
325
4/4
✓ Branch 0 taken 53168 times.
✓ Branch 1 taken 223787 times.
✓ Branch 2 taken 28535 times.
✓ Branch 3 taken 24633 times.
276955 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)));
326 }
327
328 // Returns true iff enemy is floating and blocked by a combo type or flag.
329 139611 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
330 {
331
2/2
✓ Branch 0 taken 137288 times.
✓ Branch 1 taken 2323 times.
139611 bool pit_blocks = (!(gd.moveflags & move_can_pitwalk) && !(gd.moveflags & move_can_pitfall));
332 139611 bool water_blocks = !(gd.moveflags & move_can_waterwalk);
333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139611 times.
279222 return ((special==spw_floater)&&
334
2/2
✓ Branch 0 taken 139514 times.
✓ Branch 1 taken 97 times.
139611 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
335
2/2
✓ Branch 0 taken 139509 times.
✓ Branch 1 taken 5 times.
139514 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
336
2/2
✓ Branch 0 taken 139500 times.
✓ Branch 1 taken 9 times.
139509 (MAPFLAG(dx,dy)==mfNOENEMY)||
337
2/2
✓ Branch 0 taken 139471 times.
✓ Branch 1 taken 29 times.
139500 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
338
4/4
✓ Branch 0 taken 2321 times.
✓ Branch 1 taken 137150 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 2071 times.
278692 (water_blocks && iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)) ||
339
2/2
✓ Branch 0 taken 137150 times.
✓ Branch 1 taken 2071 times.
139221 (pit_blocks && ispitfall(dx,dy))));
340 }
341
342
5/10
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115240 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 115240 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115240 times.
✗ Branch 9 not taken.
230480 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
343 115240 {
344
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 x=X;
345
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 y=Y;
346
3/6
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115240 times.
✗ Branch 5 not taken.
115240 screen_spawned=get_screen_for_world_xy(x.getInt(), y.getInt());
347 115240 id=Id;
348 115240 clk=Clk;
349
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 floor_y=y;
350 115240 ceiling=false;
351 115240 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
352 115240 grumble = movestatus = posframe = timer = ox = oy = 0;
353
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 115240 times.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115240 times.
✗ Branch 5 not taken.
115240 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
354 115240 did_armos=true;
355 115240 script_spawned=false;
356
357 115240 d = guysbuf + (id & 0xFFF);
358 115240 hp = d->hp;
359 115240 starting_hp = hp;
360 // cs = d->cset;
361 //d variables
362
363 115240 flags=d->flags;
364 115240 flags=d->flags;
365 115240 s_tile=d->s_tile; //secondary (additional) tile(s)
366 115240 type=d->type;
367 115240 dcset=d->cset;
368 115240 cs=dcset;
369
2/2
✓ Branch 0 taken 89096 times.
✓ Branch 1 taken 26144 times.
115240 anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim;
370 115240 dp=d->dp;
371 115240 wdp=d->wdp;
372 115240 wpn=d->weapon;
373 115240 wpnsprite = d-> wpnsprite; //2.6 -Z
374 115240 rate=d->rate;
375 115240 hrate=d->hrate;
376
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 dstep=d->step;
377 115240 homing=d->homing;
378 115240 dmisc1=d->attributes[0];
379 115240 dmisc2=d->attributes[1];
380 115240 dmisc3=d->attributes[2];
381 115240 dmisc4=d->attributes[3];
382 115240 dmisc5=d->attributes[4];
383 115240 dmisc6=d->attributes[5];
384 115240 dmisc7=d->attributes[6];
385 115240 dmisc8=d->attributes[7];
386 115240 dmisc9=d->attributes[8];
387 115240 dmisc10=d->attributes[9];
388 115240 dmisc11=d->attributes[10];
389 115240 dmisc12=d->attributes[11];
390 115240 dmisc13=d->attributes[12];
391 115240 dmisc14=d->attributes[13];
392 115240 dmisc15=d->attributes[14];
393 115240 dmisc16=d->attributes[15];
394 115240 dmisc17=d->attributes[16];
395 115240 dmisc18=d->attributes[17];
396 115240 dmisc19=d->attributes[18];
397 115240 dmisc20=d->attributes[19];
398 115240 dmisc21=d->attributes[20];
399 115240 dmisc22=d->attributes[21];
400 115240 dmisc23=d->attributes[22];
401 115240 dmisc24=d->attributes[23];
402 115240 dmisc25=d->attributes[24];
403 115240 dmisc26=d->attributes[25];
404 115240 dmisc27=d->attributes[26];
405 115240 dmisc28=d->attributes[27];
406 115240 dmisc29=d->attributes[28];
407 115240 dmisc30=d->attributes[29];
408 115240 dmisc31=d->attributes[30];
409 115240 dmisc32=d->attributes[31];
410
2/2
✓ Branch 0 taken 4275 times.
✓ Branch 1 taken 110965 times.
115240 if (get_qr(qr_BROKEN_ATTRIBUTE_31_32))
411 {
412 110965 dmisc31 = dmisc32;
413 110965 dmisc32 = 0;
414 110965 }
415 115240 spr_shadow=d->spr_shadow;
416 115240 spr_death=d->spr_death;
417 115240 spr_spawn=d->spr_spawn;
418
419
2/2
✓ Branch 0 taken 4724840 times.
✓ Branch 1 taken 115240 times.
4840080 for(int32_t i=0; i<edefLAST255; i++)
420 4724840 defense[i]=d->defense[i];
421
422 115240 bgsfx=d->bgsfx;
423 115240 hitsfx=d->hitsfx;
424 115240 deadsfx=d->deadsfx;
425 115240 bosspal=d->bosspal;
426
427 115240 frozentile = d->frozentile;
428
429 115240 frozencset = d->frozencset;
430 115240 frozenclock = 0;
431
2/2
✓ Branch 0 taken 1152400 times.
✓ Branch 1 taken 115240 times.
1267640 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
432
433
2/2
✓ Branch 0 taken 1959080 times.
✓ Branch 1 taken 115240 times.
2074320 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
434 //firesfx = 0; //t.b.a -Z
435 115240 isCore = true; //t.b.a
436 115240 parentCore = 0; //t.b.a
437
438 115240 firesfx = d->firesfx;
439
2/2
✓ Branch 0 taken 3687680 times.
✓ Branch 1 taken 115240 times.
3802920 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
440
2/2
✓ Branch 0 taken 3687680 times.
✓ Branch 1 taken 115240 times.
3802920 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
441
442 115240 script = d->script;
443
444
2/2
✓ Branch 0 taken 921920 times.
✓ Branch 1 taken 115240 times.
1037160 for ( int32_t q = 0; q < 8; q++ )
445 {
446 921920 initD[q] = d->initD[q];
447 921920 }
448
449 115240 stickclk = 0;
450 115240 submerged = false;
451 115240 didScriptThisFrame = false;
452 115240 ffcactivated = std::nullopt;
453 115240 hitdir = -1;
454 115240 editorflags = d->editorflags; //set by Enemy Editor
455 //Set the drawing flag for this sprite.
456
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
457
458
459
2/2
✓ Branch 0 taken 8921 times.
✓ Branch 1 taken 106319 times.
115240 if(bosspal>-1)
460 {
461
1/2
✓ Branch 0 taken 8921 times.
✗ Branch 1 not taken.
8921 loadpalset(csBOSS,pSprite(bosspal));
462 8921 }
463
464
2/2
✓ Branch 0 taken 50331 times.
✓ Branch 1 taken 64909 times.
115240 if(bgsfx>-1)
465 {
466
1/2
✓ Branch 0 taken 50331 times.
✗ Branch 1 not taken.
50331 cont_sfx(bgsfx);
467 50331 }
468
469
2/2
✓ Branch 0 taken 89096 times.
✓ Branch 1 taken 26144 times.
115240 if(get_qr(qr_NEWENEMYTILES))
470 {
471 89096 o_tile=d->e_tile;
472 89096 frate = d->e_frate;
473 89096 }
474 else
475 {
476 26144 o_tile=d->tile;
477 26144 frate = d->frate;
478 }
479
480 115240 tile=0; //init to 0 here, but set it later.
481
482 115240 scripttile = -1;
483 115240 scriptflip = -1;
484 115240 do_animation = true;
485 115240 immortal = false;
486 115240 noSlide = false;
487 115240 deathexstate = -1;
488
489 115240 hashero=false;
490
491 // If they forgot the invisibility flag, here's another failsafe:
492
4/4
✓ Branch 0 taken 5793 times.
✓ Branch 1 taken 109447 times.
✓ Branch 2 taken 5699 times.
✓ Branch 3 taken 94 times.
115240 if(o_tile==0 && type!=eeSPINTILE)
493
1/2
✓ Branch 0 taken 5699 times.
✗ Branch 1 not taken.
5699 flags |= guy_invisible;
494
495 // step = d->step/100.0;
496 // To preserve the odd step values for Keese & Gleeok heads. -L
497
5/8
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12297 times.
✓ Branch 5 taken 102943 times.
✓ Branch 6 taken 12297 times.
✗ Branch 7 not taken.
115240 if(dstep==62.0) dstep+=0.5;
498
5/8
✓ Branch 0 taken 102943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102943 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 699 times.
✓ Branch 5 taken 102244 times.
✓ Branch 6 taken 699 times.
✗ Branch 7 not taken.
102943 else if(dstep==89) dstep-=1/9;
499
500
5/10
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115240 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 115240 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115240 times.
✗ Branch 9 not taken.
115240 step = zslongToFix(dstep*100);
501
502
503 115240 item_set = d->item_set;
504 115240 grumble = d->grumble;
505
506
2/2
✓ Branch 0 taken 90351 times.
✓ Branch 1 taken 24889 times.
115240 if(frate == 0)
507 24889 frate = 256;
508
509 115240 leader = itemguy = dying = scored = false;
510 115240 canfreeze = count_enemy = true;
511
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 mainguy = !(flags & guy_doesnt_count);
512
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 dir = zc_oldrand()&3;
513
514 //2.6 Enemy Editor Hit and TIle Sizes
515
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 115231 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
115240 if ( ((d->SIZEflags&OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
516 // al_trace("Enemy txsz:%i\n", txsz);
517
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 115231 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
115240 if ( ((d->SIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
518
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 115233 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
115240 if ( ((d->SIZEflags&OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
519
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 115233 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
115240 if ( ((d->SIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
520
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115240 if ( ((d->SIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
521
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 if ( (d->SIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
522
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 if ( (d->SIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
523 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
524
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115240 if ( (d->SIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115240 times.
115240 if ( (d->SIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
526 {
527 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
528 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
529 }
530
531
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115240 if ( (d->SIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
532
533 115240 SIZEflags = d->SIZEflags;
534
535
8/10
✓ Branch 0 taken 114991 times.
✓ Branch 1 taken 249 times.
✓ Branch 2 taken 366 times.
✓ Branch 3 taken 114874 times.
✓ Branch 4 taken 366 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 366 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 365 times.
115240 if((wpn==ewBomb || wpn==ewSBomb) && type!=eeOTHER && type!=eeFIRE && (type!=eeWALK || dmisc2 != e2tBOMBCHU))
536 1 wpn = 0;
537
538 //tile should never be 0 after init --Z (failsafe)
539
4/6
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107998 times.
✓ Branch 5 taken 7242 times.
115240 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
540
541 //Moveflags; for gravity and pit interaction
542 115240 moveflags = d->moveflags;
543
3/4
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✓ Branch 3 taken 97534 times.
115240 if(!can_pitfall(false))
544 {
545 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
546
2/4
✓ Branch 0 taken 17706 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✗ Branch 3 not taken.
17706 moveflags &= ~move_can_pitfall;
547
2/4
✓ Branch 0 taken 17706 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17706 times.
✗ Branch 3 not taken.
17706 moveflags &= ~move_can_waterdrown;
548 17706 }
549
550 115240 shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false;
551
552 115240 specialsfx = d->specialsfx;
553
1/2
✓ Branch 0 taken 115240 times.
✗ Branch 1 not taken.
115240 weap_data = d->weap_data;
554 115240 }
555
556 114983 enemy::~enemy()
557 114983 {
558
1/2
✓ Branch 0 taken 114983 times.
✗ Branch 1 not taken.
114983 FFCore.destroySprite(this);
559
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 114970 times.
114983 if(hashero)
560 {
561
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 Hero.setEaten(0);
562 13 hashero=false;
563 13 }
564 114983 }
565
566 bool enemy::is_move_paused()
567 {
568 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
569 }
570
571 7024 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
572 {
573 7024 int32_t yg = (special==spw_floater)?8:0;
574 7024 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
575
576
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_x == -1000)
577 input_x = dx;
578
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_y == -1000)
579 input_y = dy;
580
581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
14048 if(!(moveflags & move_ignore_screenedge)
582
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7024 times.
✓ Branch 4 taken 6707 times.
✓ Branch 5 taken 317 times.
7024 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
583
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 || ((input_x+hit_width-1) >= (world_w-16+nb)) || ((input_y+hit_height-1) >= (world_h-16+nb))))
584 return true;
585
586
4/6
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 6934 times.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
7024 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
587 {
588 if(ispitfall(dx,dy))
589 return true;
590 }
591
592 7024 bool flying = false;
593 7024 bool cansolid = false;
594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
7024 if(moveflags & move_ignore_solidity)
595 cansolid = true;
596
2/4
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7024 switch(special)
597 {
598 case spw_clipbottomright:
599 if(dy>=128 || dx>=208) return true;
600 break;
601 case spw_clipright:
602 break; //if(input_x>=208) return true; break;
603
604 case spw_wizzrobe: // fall through
605 case spw_floater: // Special case for fliers and wizzrobes - hack!
606 {
607
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
317 if(isdungeon(screen_spawned) && !(moveflags & move_ignore_screenedge))
608 {
609 if(dy < 32-yg || dy >= 144) return true;
610 if(dx < 32 || dx >= 224) return true;
611 }
612
2/4
✓ Branch 0 taken 317 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 317 times.
✗ Branch 3 not taken.
317 if(!(moveflags & move_ignore_blockflags) && flyerblocked(dx, dy, special, kb))
613 return true;
614 317 cansolid = true;
615 317 flying = true;
616 }
617 317 }
618
619 7024 dx = TRUNCATE_HALF_TILE(dx);
620 7024 dy = TRUNCATE_HALF_TILE(dy);
621
622
4/6
✓ Branch 0 taken 6707 times.
✓ Branch 1 taken 317 times.
✓ Branch 2 taken 6707 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6707 times.
✗ Branch 5 not taken.
7024 if(!flying && !(moveflags & move_ignore_blockflags) && groundblocked(dx,dy,kb)) return true;
623
624
4/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7024 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7024 times.
7024 if (dx < 0 || dx >= world_w || dy < 0 || dy >= world_h)
625 return !(moveflags & move_ignore_screenedge);
626
627 // TODO: could this reuse _walkflag?
628
629 //_walkflag code
630 7024 mapscr* s0 = get_scr_for_world_xy_layer(dx, dy, 0);
631
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 mapscr* s1 = s0->layermap[0]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 1) : nullptr;
632
2/2
✓ Branch 0 taken 1038 times.
✓ Branch 1 taken 5986 times.
7024 mapscr* s2 = s0->layermap[1]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 2) : nullptr;
633
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 if (!s1 || !s1->valid) s1 = s0;
634
4/4
✓ Branch 0 taken 1038 times.
✓ Branch 1 taken 5986 times.
✓ Branch 2 taken 383 times.
✓ Branch 3 taken 655 times.
7024 if (!s2 || !s2->valid) s2 = s0;
635
636 7024 int32_t cpos = COMBOPOS(dx%256, dy%176);
637
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 int32_t ci = s0->data[cpos], ci1 = (s1?s1:s0)->data[cpos], ci2 = (s2?s2:s0)->data[cpos];
638 7024 newcombo c = combobuf[ci];
639
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 newcombo c1 = combobuf[ci1];
640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
7024 newcombo c2 = combobuf[ci2];
641
642 7024 int32_t b=1;
643
2/2
✓ Branch 0 taken 3446 times.
✓ Branch 1 taken 3578 times.
7024 if(dx&8) b<<=2;
644
2/2
✓ Branch 0 taken 3374 times.
✓ Branch 1 taken 3650 times.
7024 if(dy&8) b<<=1;
645
646 #define iwtr(cmb, x, y, shallow) \
647 (shallow \
648 ? iswaterex_z3(cmb, -1, dx, dy, false, false, false, true, false) \
649 && !iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false) \
650 : iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false))
651
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool wtr = iwtr(ci, dx, dy, false);
652
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3473 times.
✓ Branch 3 taken 3551 times.
✓ Branch 4 taken 3473 times.
✗ Branch 5 not taken.
7024 bool shwtr = iwtr(ci, dx, dy, true);
653
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool pit = ispitfall(dx,dy);
654
655
5/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 6934 times.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 90 times.
✗ Branch 7 not taken.
7024 bool canwtr = (moveflags & move_can_waterwalk) || ((moveflags & move_can_waterdrown) && kb);
656
5/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 6934 times.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 90 times.
7024 bool canpit = (moveflags & move_can_pitwalk) || ((moveflags & move_can_pitfall) && kb);
657
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needwtr = (moveflags & move_only_waterwalk);
658
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needshwtr = (moveflags & move_only_shallow_waterwalk);
659
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needpit = (moveflags & move_only_pitwalk);
660
661
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
7024 if(!cansolid)
662 {
663 6707 int32_t cwalkflag = c.walk & 0xF;
664
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6707 if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s1)
666 {
667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c1.type == cBRIDGE)
668 {
669 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
670 {
671 int efflag = (c1.walk & 0xF0)>>4;
672 int newsolid = (c1.walk & 0xF);
673 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
674 }
675 else cwalkflag &= c1.walk;
676 }
677 6707 else cwalkflag |= c1.walk & 0xF;
678 6707 }
679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s2)
680 {
681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c2.type == cBRIDGE)
682 {
683 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
684 {
685 int efflag = (c2.walk & 0xF0)>>4;
686 int newsolid = (c2.walk & 0xF);
687 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
688 }
689 else cwalkflag &= c2.walk;
690 }
691 6707 else cwalkflag |= c2.walk & 0xF;
692 6707 }
693
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 6468 times.
6707 if(cwalkflag & b)
694 239 return true;
695 6468 }
696
3/6
✓ Branch 0 taken 6785 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6785 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6785 times.
6785 if(needwtr || needshwtr || needpit)
697 {
698 bool ret = true;
699 if (needwtr && wtr) ret = false;
700 else if (needshwtr && shwtr) ret = false;
701 else if (needpit && pit) ret = false;
702 return ret;
703 }
704
3/4
✓ Branch 0 taken 3473 times.
✓ Branch 1 taken 3312 times.
✓ Branch 2 taken 3473 times.
✗ Branch 3 not taken.
6785 else if(wtr && !canwtr)
705 return true;
706
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6785 else if(pit && !canpit)
707 return true;
708
709 6785 return false;
710 7024 }
711
712 1535 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
713 {
714
3/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1111 times.
✓ Branch 2 taken 424 times.
✗ Branch 3 not taken.
1535 if(!(dx || dy)) return true;
715 1535 zfix bx = x+hxofs, by = y+hyofs; //left/top
716 1535 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
717
3/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 1019 times.
✗ Branch 3 not taken.
1535 if(!ign_sv && dy < 0) //check gravity
718 {
719 if((moveflags & move_obeys_grav) && isSideViewGravity())
720 return false;
721 }
722
723
2/4
✓ Branch 0 taken 1535 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1535 times.
1535 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
724
725
3/4
✓ Branch 0 taken 1111 times.
✓ Branch 1 taken 424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1111 times.
1535 if(dx && !dy)
726 {
727
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 341 times.
1111 if(dx < 0)
728 {
729
2/4
✓ Branch 0 taken 770 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 770 times.
770 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
730 770 int mx = (bx+dx).getFloor();
731
2/2
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 770 times.
3746 for(zfix ty = 0; by+ty < ry; ty += 8)
732 {
733
1/2
✓ Branch 0 taken 2976 times.
✗ Branch 1 not taken.
2976 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
734 return false;
735 2976 }
736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 770 times.
770 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
737 return false;
738
3/4
✓ Branch 0 taken 736 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 736 times.
✗ Branch 3 not taken.
770 if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this))
739 return false;
740 770 }
741 else
742 {
743 341 int mx = (rx+dx).getCeil();
744 341 int lx = mx-hit_width+1;
745
2/2
✓ Branch 0 taken 2142 times.
✓ Branch 1 taken 340 times.
2482 for(zfix ty = 0; by+ty < ry; ty += 8)
746 {
747
2/2
✓ Branch 0 taken 2141 times.
✓ Branch 1 taken 1 times.
2142 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
748 1 return false;
749 2141 }
750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
751 return false;
752
2/4
✓ Branch 0 taken 340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
✗ Branch 3 not taken.
340 if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this))
753 return false;
754 }
755 1110 }
756
2/4
✓ Branch 0 taken 424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 424 times.
424 else if(dy && !dx)
757 {
758
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 109 times.
424 if(dy < 0)
759 {
760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 special = (special==spw_clipbottomright)?spw_none:special;
761 315 int my = (by+dy).getFloor();
762
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 77 times.
469 for(zfix tx = 0; bx+tx < rx; tx += 8)
763 {
764
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 238 times.
392 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
765 238 return false;
766 154 }
767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(scr_walkflag(rx, my, special, up, bx, my, kb))
768 return false;
769
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
77 if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this))
770 return false;
771 77 }
772 else
773 {
774 109 int my = (ry+dy).getCeil();
775 109 int ly = my-hit_height+1;
776
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 109 times.
327 for(zfix tx = 0; bx+tx < rx; tx += 8)
777 {
778
1/2
✓ Branch 0 taken 218 times.
✗ Branch 1 not taken.
218 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
779 return false;
780 218 }
781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
782 return false;
783
3/4
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
109 if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this))
784 return false;
785 }
786 186 }
787 else //! Untested, and currently unused.
788 {
789 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
790 }
791 1296 return true;
792 1535 }
793
794 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
795 {
796 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
797 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
798
799 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
800
801 if(nosolid && collide_object(bx,by,hit_width,hit_height,this))
802 return false;
803 for(zfix ty = 0; by+ty < ry; ty += 8)
804 {
805 for(zfix tx = 0; bx+tx < rx; tx += 8)
806 {
807 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
808 return false;
809 }
810 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
811 return false;
812 }
813 for(zfix tx = 0; bx+tx < rx; tx += 8)
814 {
815 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
816 return false;
817 }
818 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
819 return false;
820 return true;
821 }
822
823 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
824 {
825 auto oxsz = hit_width, oysz = hit_height;
826 if(nwid > -1) hit_width = nwid;
827 if(nhei > -1) hit_height = nhei;
828 bool ret = scr_canplace(dx,dy,special,kb);
829 hit_width = oxsz; hit_height = oysz;
830 return ret;
831 }
832
833 1311 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
834 {
835 1311 bool ret = true;
836
3/8
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1019 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1311 if(!ign_sv && dy < 0 && (moveflags & move_obeys_grav) && isSideViewGravity())
837 dy = 0;
838 1311 const int scl = 2;
839
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 1345 times.
✓ Branch 2 taken 294 times.
✓ Branch 3 taken 1311 times.
1605 while(abs(dx) > scl || abs(dy) > scl)
840 {
841
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 34 times.
294 if(abs(dx) > abs(dy))
842 {
843 260 int32_t tdx = dx.sign() * scl;
844
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
845 260 dx -= tdx;
846 else
847 {
848 if(earlyret) return false;
849 dx = tdx;
850 ret = false;
851 }
852 260 }
853 else
854 {
855 34 int32_t tdy = dy.sign() * scl;
856
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 7 times.
34 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
857 27 dy -= tdy;
858 else
859 {
860
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(earlyret) return false;
861 7 dy = tdy;
862 7 ret = false;
863 }
864 }
865 }
866
867
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 1111 times.
1311 if(dx)
868 {
869
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 1 times.
1111 if(scr_canmove(dx, 0, special, kb, ign_sv))
870 1110 x += dx;
871 else
872 {
873
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(earlyret) return false;
874 ret = false;
875 int xsign = dx.sign();
876 while(scr_canmove(xsign, 0, special, kb, ign_sv))
877 {
878 x += xsign;
879 dx -= xsign;
880 }
881 if(dx)
882 {
883 dx.doDecBound(0,-9999, 0,9999);
884 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
885 if(scr_canmove(val, 0, special, kb, ign_sv))
886 {
887 retval = val;
888 return BSEARCH_CONTINUE_AWAY0;
889 }
890 else return BSEARCH_CONTINUE_TOWARD0;
891 });
892 x += dx;
893 }
894 }
895 1110 }
896
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 200 times.
1310 if(dy)
897 {
898
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 14 times.
200 if(scr_canmove(0, dy, special, kb, ign_sv))
899 186 y += dy;
900 else
901 {
902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(earlyret) return false;
903 14 ret = false;
904 14 int ysign = dy.sign();
905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 while(scr_canmove(0, ysign, special, kb, ign_sv))
906 {
907 y += ysign;
908 dy -= ysign;
909 }
910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(dy)
911 {
912 14 dy.doDecBound(0,-9999, 0,9999);
913
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
224 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(scr_canmove(0, val, special, kb, ign_sv))
915 {
916 retval = val;
917 return BSEARCH_CONTINUE_AWAY0;
918 }
919 210 else return BSEARCH_CONTINUE_TOWARD0;
920 210 });
921 14 y += dy;
922 14 }
923 }
924 200 }
925 1310 return ret;
926 1311 }
927
928 754 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
929 {
930
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 752 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
754 static const zfix diagrate = zslongToFix(7071);
931
5/13
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 754 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 479 times.
✓ Branch 7 taken 259 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
754 switch(NORMAL_DIR(dir))
932 {
933 case up:
934 return movexy(0, -px, special, kb, false, earlyret);
935 case down:
936 16 return movexy(0, px, special, kb, false, earlyret);
937 case left:
938 479 return movexy(-px, 0, special, kb, false, earlyret);
939 case right:
940 259 return movexy(px, 0, special, kb, false, earlyret);
941 case r_up:
942 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
943 case r_down:
944 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
945 case l_up:
946 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
947 case l_down:
948 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
949 }
950 return false;
951 754 }
952
953 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
954 {
955 double v = degrees.getFloat() * PI / 180.0;
956 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
957 return movexy(dx, dy, special, kb, false, earlyret);
958 }
959
960 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
961 {
962 zfix tx = x, ty = y;
963 bool ret = movexy(dx, dy, special, kb, false, true);
964 x = tx;
965 y = ty;
966 return ret;
967 }
968 754 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
969 {
970 754 zfix tx = x, ty = y;
971 754 bool ret = moveDir(dir, px, special, kb, true);
972 754 x = tx;
973 754 y = ty;
974 754 return ret;
975 }
976 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
977 {
978 zfix tx = x, ty = y;
979 bool ret = moveAtAngle(degrees, px, special, kb, true);
980 x = tx;
981 y = ty;
982 return ret;
983 }
984
985 // Handle pitfalls
986 38011691 bool enemy::do_falling(int32_t index)
987 {
988
2/2
✓ Branch 0 taken 38009324 times.
✓ Branch 1 taken 2367 times.
38011691 if(fallclk > 0)
989 {
990
4/4
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 2333 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 20 times.
2367 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x));
991
2/2
✓ Branch 0 taken 2345 times.
✓ Branch 1 taken 22 times.
2367 if(!--fallclk)
992 {
993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(immortal) //Keep alive forever
994 ++fallclk; //force another frame of falling.... forever.
995
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 else if(dying) //Give 1 frame for script revival
996 {
997
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(flags&guy_never_return)
998 never_return(screen_spawned, index);
999
1000
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(leader)
1001 kill_em_all();
1002
1003 //leave_item(); //Don't drop items in pits!
1004 11 stop_bgsfx(index);
1005 11 return true;
1006 }
1007 else
1008 {
1009 11 try_death(true); //Force death
1010 11 ++fallclk; //force another frame of falling
1011 }
1012 11 }
1013
1014 2356 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
1015 2356 cs = spr.csets & 0xF;
1016
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 int32_t fr = spr.frames ? spr.frames : 1;
1017
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 int32_t spd = spr.speed ? spr.speed : 1;
1018 2356 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
1019
2/2
✓ Branch 0 taken 1148 times.
✓ Branch 1 taken 1208 times.
2356 tile = spr.tile + zc_min(animclk / spd, fr-1);
1020 2356 }
1021 38011680 return false;
1022 38011691 }
1023
1024 // Handle drowning in water
1025 38009324 bool enemy::do_drowning(int32_t index)
1026 {
1027
1/2
✓ Branch 0 taken 38009324 times.
✗ Branch 1 not taken.
38009324 if(drownclk > 0)
1028 {
1029 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x));
1030 //!TODO: Drown SFX
1031 if(!--drownclk)
1032 {
1033 if(immortal) //Keep alive forever
1034 ++drownclk; //force another frame of falling.... forever.
1035 else if(dying) //Give 1 frame for script revival
1036 {
1037 if(flags&guy_never_return)
1038 never_return(screen_spawned, index);
1039
1040 if(leader)
1041 kill_em_all();
1042
1043 //leave_item(); //Don't drop items in pits!
1044 stop_bgsfx(index);
1045 return true;
1046 }
1047 else
1048 {
1049 try_death(true); //Force death
1050 ++drownclk; //force another frame of falling
1051 }
1052 }
1053
1054 bool lava = (drownCombo && combobuf[drownCombo].usrflags&cflag1);
1055 wpndata &spr = wpnsbuf[QMisc.sprites[lava ? sprLAVADROWN : sprDROWN]];
1056 cs = spr.csets & 0xF;
1057 int32_t fr = spr.frames ? spr.frames : 1;
1058 int32_t spd = spr.speed ? spr.speed : 1;
1059 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1060 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1061 }
1062 38009324 return false;
1063 38009324 }
1064
1065 // Supplemental animation code that all derived classes should call
1066 // as a return value for animate().
1067 // Handles the death animation and returns true when enemy is finished.
1068 38674710 bool enemy::Dead(int32_t index)
1069 {
1070
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 38672881 times.
38674710 if(immortal)
1071 {
1072 1829 dying = false;
1073 1829 return false;
1074 }
1075
2/2
✓ Branch 0 taken 765577 times.
✓ Branch 1 taken 37907304 times.
38672881 if(dying)
1076 {
1077
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 765576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
765577 if(deathexstate > -1 && deathexstate < 32)
1078 {
1079 1 setxmapflag(screen_spawned, 1<<deathexstate);
1080 1 deathexstate = -1;
1081 1 }
1082 765577 --clk2;
1083
1084
4/4
✓ Branch 0 taken 725657 times.
✓ Branch 1 taken 39920 times.
✓ Branch 2 taken 38736 times.
✓ Branch 3 taken 3242 times.
765577 if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
1085
2/2
✓ Branch 0 taken 41978 times.
✓ Branch 1 taken 683679 times.
725657 && hp>-1000) // not killed by ringleader
1086 38736 death_sfx();
1087
1088
2/2
✓ Branch 0 taken 722043 times.
✓ Branch 1 taken 43534 times.
765577 if(clk2==0)
1089 {
1090
2/2
✓ Branch 0 taken 42830 times.
✓ Branch 1 taken 704 times.
43534 if(flags&guy_never_return)
1091 704 never_return(screen_spawned, index);
1092
1093
2/2
✓ Branch 0 taken 43463 times.
✓ Branch 1 taken 71 times.
43534 if(leader)
1094 71 kill_em_all();
1095
1096 43534 leave_item();
1097 43534 }
1098
1099 765577 stop_bgsfx(index);
1100 765577 return (clk2==0);
1101 }
1102
1103 37907304 return false;
1104 38674710 }
1105
1106 // Basic animation code that all derived classes should call.
1107 // The one with an index is the one that is called by
1108 // the guys sprite list; index is the enemy's index in the list.
1109 38011947 bool enemy::animate(int32_t index)
1110 {
1111 38011947 update_current_screen();
1112
2/2
✓ Branch 0 taken 1723938 times.
✓ Branch 1 taken 36288009 times.
38011947 if(sclk <= 0) hitdir = -1;
1113
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 38011691 times.
38011947 if(switch_hooked)
1114 {
1115
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT))
1116 {
1117 //Run its script
1118 if (!didScriptThisFrame)
1119 {
1120 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1121 {
1122 return 0; //Avoid NULLPO if this object deleted itself
1123 }
1124 }
1125 }
1126 256 return false;
1127 }
1128
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 38011680 times.
38011691 if(do_falling(index)) return true;
1129
2/2
✓ Branch 0 taken 2356 times.
✓ Branch 1 taken 38009324 times.
38011680 else if(fallclk)
1130 {
1131 //clks
1132
2/2
✓ Branch 0 taken 1652 times.
✓ Branch 1 taken 704 times.
2356 if(hclk>0)
1133 704 --hclk;
1134
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if(stunclk>0)
1135 --stunclk;
1136
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if ( frozenclock > 0 )
1137 --frozenclock;
1138
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if(hashero)
1139 {
1140 Hero.setX(x);
1141 Hero.setY(y);
1142 Hero.fallCombo = fallCombo;
1143 Hero.fallclk = fallclk;
1144
1145 if(hashero)
1146 {
1147 hashero = false; //Let Hero go if falling
1148 Hero.setEaten(0);
1149 }
1150 }
1151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2356 times.
2356 if (!didScriptThisFrame)
1152 {
1153 2356 run_script(MODE_NORMAL);
1154 2356 }
1155 2356 return false;
1156 }
1157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38009324 times.
38009324 if(do_drowning(index)) return true;
1158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38009324 times.
38009324 else if(drownclk)
1159 {
1160 //clks
1161 if(hclk>0)
1162 --hclk;
1163 if(stunclk>0)
1164 --stunclk;
1165 if ( frozenclock > 0 )
1166 --frozenclock;
1167 if(hashero)
1168 {
1169 Hero.setX(x);
1170 Hero.setY(y);
1171 Hero.drownclk = drownclk;
1172
1173 if(hashero)
1174 {
1175 hashero = false; //Let Hero go if falling
1176 Hero.setEaten(0);
1177 }
1178 }
1179 if (!didScriptThisFrame)
1180 {
1181 run_script(MODE_NORMAL);
1182 }
1183 return false;
1184 }
1185 38009324 int32_t nx = real_x(x);
1186 38009324 int32_t ny = real_y(y);
1187
1188
4/4
✓ Branch 0 taken 27480339 times.
✓ Branch 1 taken 10528985 times.
✓ Branch 2 taken 5660595 times.
✓ Branch 3 taken 21819744 times.
38009324 if(ox!=nx || oy!=ny)
1189 {
1190 16189580 posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2);
1191 16189580 }
1192
1193 38009324 ox = nx;
1194 38009324 oy = ny;
1195
1196 // Maybe they fell off the bottom in sideview, or were moved by a script.
1197
1198 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
1199
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 38007495 times.
38009324 if ( immortal )
1200 {
1201 //skip, as it can go out of bounds, from immortality
1202 1829 }
1203
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38007495 times.
✓ Branch 2 taken 38007495 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38007495 times.
38007495 else if ( (moveflags & move_ignore_screenedge) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
1204 {
1205 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
1206 }
1207
2/2
✓ Branch 0 taken 37975894 times.
✓ Branch 1 taken 31601 times.
38007495 else if (OUTOFBOUNDS(id, x, y))
1208 {
1209 31601 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
1210 31601 }
1211 //fall down
1212 38009324 handle_termv();
1213
6/6
✓ Branch 0 taken 27192563 times.
✓ Branch 1 taken 10816761 times.
✓ Branch 2 taken 10546498 times.
✓ Branch 3 taken 27462826 times.
✓ Branch 4 taken 511441 times.
✓ Branch 5 taken 10035057 times.
38009324 if((enemycanfall(id) || (moveflags & move_obeys_grav) )&& fading != fade_flicker && clk>=0)
1214 {
1215
2/2
✓ Branch 0 taken 387698 times.
✓ Branch 1 taken 9647359 times.
10035057 if(isSideViewGravity())
1216 {
1217
1/2
✓ Branch 0 taken 387698 times.
✗ Branch 1 not taken.
387698 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
1218 {
1219
2/2
✓ Branch 0 taken 230320 times.
✓ Branch 1 taken 157378 times.
387698 if(!isOnSideviewPlatform())
1220 {
1221 157378 bool willHitSVPlatform = false;
1222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH)?hit_width:16;
1223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT)?hit_height:16;
1224
2/2
✓ Branch 0 taken 157378 times.
✓ Branch 1 taken 157378 times.
314756 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
1225 {
1226
5/8
✓ Branch 0 taken 23519 times.
✓ Branch 1 taken 133859 times.
✓ Branch 2 taken 23519 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23519 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 157378 times.
✗ Branch 7 not taken.
157378 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
1227 {
1228 willHitSVPlatform = true;
1229 break;
1230 }
1231 157378 }
1232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 if(willHitSVPlatform)
1233 {
1234 y+=fall/100;
1235 //y-=int32_t(y)%16; //Fix to top of SV Ladder
1236 do_fix(y, 16); //Fix to top of SV Ladder
1237 fall = 0;
1238 }
1239 else
1240 {
1241 157378 y+=fall/100;
1242
2/2
✓ Branch 0 taken 17812 times.
✓ Branch 1 taken 139566 times.
157378 if(fall <= get_terminalv())
1243 139566 fall += get_grav_fall();
1244 }
1245 157378 }
1246 else
1247 {
1248
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 230043 times.
230320 if(fall!=0) // Only fix pos once
1249 {
1250 //y-=(int32_t)y%8; // Fix position
1251 277 do_fix(y, 8); //Fix position
1252 277 }
1253
1254 230320 fall = 0;
1255 }
1256 387698 }
1257 else
1258 {
1259 if(isOnSideviewPlatform())
1260 fall = 0;
1261 else
1262 {
1263 zfix fall_amnt = fall/100;
1264 bool hit = false;
1265 while(fall_amnt >= 1)
1266 {
1267 --fall_amnt;
1268 ++y;
1269 if(isOnSideviewPlatform())
1270 {
1271 y = y.getInt();
1272 fall_amnt = 0;
1273 hit = true;
1274 break;
1275 }
1276 }
1277 if(fall_amnt > 0)
1278 y += fall_amnt;
1279 if(fall_amnt < 0)
1280 {
1281 if(!movexy(0,fall_amnt,spw_none,false,!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)))
1282 hit = true;
1283 }
1284 if(hit)
1285 fall = 0;
1286 else if(fall <= get_terminalv())
1287 fall += get_grav_fall();
1288 }
1289 }
1290 387698 }
1291 else
1292 {
1293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9647359 times.
9647359 if (!(moveflags & move_no_fake_z))
1294 {
1295
2/2
✓ Branch 0 taken 5079296 times.
✓ Branch 1 taken 4568063 times.
9647359 if(fakefall!=0)
1296 4568063 fakez-=(fakefall/100);
1297
1298
2/2
✓ Branch 0 taken 4568063 times.
✓ Branch 1 taken 5079296 times.
9647359 if(fakez<0)
1299 4568063 fakez = fakefall = 0;
1300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5079296 times.
5079296 else if(fakefall <= get_terminalv())
1301 5079296 fakefall += get_grav_fall();
1302
1303
5/6
✓ Branch 0 taken 9647359 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5079296 times.
✓ Branch 3 taken 4568063 times.
✓ Branch 4 taken 4582310 times.
✓ Branch 5 taken 496986 times.
9647359 if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
1304 9647359 }
1305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9647359 times.
9647359 if (!(moveflags & move_no_real_z))
1306 {
1307
2/2
✓ Branch 0 taken 5512182 times.
✓ Branch 1 taken 4135177 times.
9647359 if(fall!=0)
1308 4135177 z-=(fall/100);
1309
1310
2/2
✓ Branch 0 taken 4120605 times.
✓ Branch 1 taken 5526754 times.
9647359 if(z<0)
1311 4120605 z = fall = 0;
1312
2/2
✓ Branch 0 taken 10057 times.
✓ Branch 1 taken 5516697 times.
5526754 else if(fall <= get_terminalv())
1313 5516697 fall += get_grav_fall();
1314
1315
6/6
✓ Branch 0 taken 9605145 times.
✓ Branch 1 taken 42214 times.
✓ Branch 2 taken 5484540 times.
✓ Branch 3 taken 4120605 times.
✓ Branch 4 taken 4990689 times.
✓ Branch 5 taken 493851 times.
9647359 if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
1316 9647359 }
1317
1318 }
1319 10035057 }
1320 38009324 handle_termv();
1321
9/10
✓ Branch 0 taken 29780223 times.
✓ Branch 1 taken 8229101 times.
✓ Branch 2 taken 28485223 times.
✓ Branch 3 taken 1295000 times.
✓ Branch 4 taken 28485223 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4179477 times.
✓ Branch 7 taken 25600746 times.
✓ Branch 8 taken 18452882 times.
✓ Branch 9 taken 22632359 times.
38009324 if (can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1322 {
1323
4/4
✓ Branch 0 taken 22216835 times.
✓ Branch 1 taken 415524 times.
✓ Branch 2 taken 13056224 times.
✓ Branch 3 taken 9160611 times.
22632359 if (!isSideViewGravity() && (moveflags & move_can_pitfall))
1324 9160611 fallCombo = check_pits();
1325
4/4
✓ Branch 0 taken 415524 times.
✓ Branch 1 taken 22216835 times.
✓ Branch 2 taken 141898 times.
✓ Branch 3 taken 22074937 times.
22632359 if (!(isSideViewGravity() && get_qr(qr_OLD_SPRITE_FALL_DROWN)) && (moveflags & move_can_waterdrown))
1326 141898 drownCombo = check_water();
1327 22632359 }
1328
1329 74915088 runKnockback(); //scripted knockback handling
1330
1331 // clk is incremented here
1332
2/2
✓ Branch 0 taken 72604719 times.
✓ Branch 1 taken 2310369 times.
74915088 if(++clk >= frate)
1333 2310369 clk=0;
1334
1335 // hit and death handling
1336
2/2
✓ Branch 0 taken 1255709 times.
✓ Branch 1 taken 73659379 times.
74915088 if(hclk>0)
1337 1255709 --hclk;
1338
1339
2/2
✓ Branch 0 taken 676245 times.
✓ Branch 1 taken 74238843 times.
74915088 if(stunclk>0)
1340 676245 --stunclk;
1341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74915088 times.
74915088 if ( frozenclock > 0 )
1342 --frozenclock;
1343
1344
5/6
✓ Branch 0 taken 14876 times.
✓ Branch 1 taken 74900212 times.
✓ Branch 2 taken 124 times.
✓ Branch 3 taken 14752 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 124 times.
74915088 if(ceiling && z <= 0 && fakez <= 0)
1345 124 ceiling = false;
1346
1347 74915088 try_death();
1348
1349 74915088 scored=false;
1350
1351 74915088 ++c_clk;
1352
1353 //Run its script
1354
2/2
✓ Branch 0 taken 36930581 times.
✓ Branch 1 taken 37984507 times.
74915088 if (!didScriptThisFrame)
1355 {
1356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37984507 times.
37984507 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1357 {
1358 return 0; //Avoid NULLPO if this object deleted itself
1359 }
1360 37984507 }
1361
1362 // returns true when enemy is defeated
1363 74915088 return Dead(index);
1364 74917711 }
1365
1366 38761623 bool enemy::setSolid(bool set)
1367 {
1368
1/2
✓ Branch 0 taken 38761623 times.
✗ Branch 1 not taken.
38761623 bool actual = set && !isSubmerged();
1369 38761623 bool ret = solid_object::setSolid(actual);
1370 38761623 solid = set;
1371 38761623 return ret;
1372 }
1373 void enemy::doContactDamage(int32_t hdir)
1374 {
1375 Hero.hithero(guys.find(this), hdir);
1376 }
1377
1378 22405 void enemy::solid_push(solid_object *obj)
1379 {
1380
1/2
✓ Branch 0 taken 22405 times.
✗ Branch 1 not taken.
22405 if(obj == this) return; //can't push self
1381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22405 times.
22405 if(moveflags&move_not_pushable) return; //not pushable
1382 22405 zfix dx, dy;
1383 22405 int32_t hdir = -1;
1384 22405 solid_push_int(obj,dx,dy,hdir,true);
1385
1386
4/4
✓ Branch 0 taken 22292 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 150 times.
✓ Branch 3 taken 22142 times.
22405 if(!dx && !dy) return;
1387
1388 263 bool t = obj->getTempNonsolid();
1389 263 obj->setTempNonsolid(true);
1390
1391 263 int32_t ydir = dy > 0 ? down : up;
1392 263 int32_t xdir = dx > 0 ? right : left;
1393
1394 263 auto special = isflier(id) ? spw_floater : spw_none;
1395
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 7 times.
263 if(!movexy(dx,dy,special,true,true))
1396 {
1397 //Crushed?
1398 7 }
1399
1400 263 obj->setTempNonsolid(t);
1401 22405 }
1402 22405 bool enemy::is_unpushable() const
1403 {
1404 22405 return isSubmerged();
1405 }
1406 22087 bool enemy::sideview_mode() const
1407 {
1408
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22087 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22087 return isSideViewGravity() && (moveflags&move_obeys_grav) && !(moveflags&move_not_pushable);
1409 }
1410
1411 3234 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
1412 {
1413 3234 int32_t yg = (special==spw_floater)?8:0;
1414 3234 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1415
1416
8/10
✓ Branch 0 taken 2364 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 814 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 870 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 870 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2368 times.
✓ Branch 9 taken 3238 times.
3234 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1417 4732 return true;
1418
1419 3238 bool isInDungeon = isdungeon(screen_spawned);
1420
3/4
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 2976 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 262 times.
3238 if(isInDungeon || special==spw_wizzrobe)
1421 {
1422
7/8
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 604 times.
✓ Branch 5 taken 1779 times.
✓ Branch 6 taken 604 times.
✗ Branch 7 not taken.
2976 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
1423 1199 return true;
1424
1425
7/8
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 1187 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 595 times.
✓ Branch 5 taken 595 times.
✓ Branch 6 taken 595 times.
✗ Branch 7 not taken.
1779 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
1426
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1190 if(special!=spw_door) // walk in door way
1427 return true;
1428 595 }
1429
1430
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 795 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
857 if(!(moveflags & move_can_pitwalk) && !(moveflags & move_can_pitfall)) //Don't walk into pits (knockback doesn't call this func)
1431 {
1432
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
124 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1433
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1434 return true;
1435 62 }
1436
1437
1/4
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
857 switch(special)
1438 {
1439 case spw_clipbottomright:
1440 if(dy>=128 || dx>=208) return true;
1441 break;
1442 case spw_clipright:
1443 break; //if(x>=208) return true; break;
1444
1445 case spw_wizzrobe: // fall through
1446 case spw_floater: // Special case for fliers and wizzrobes - hack!
1447 {
1448
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 595 times.
857 if(isInDungeon)
1449 {
1450
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dy < 32-yg || dy >= 144) return true;
1451
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dx < 32 || dx >= 224) return true;
1452 595 }
1453 857 return false;
1454 }
1455 }
1456
1457 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1458 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1459
1460 if(special==spw_water)
1461 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1462
1463 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1464 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
1465 870 }
1466
1467 6575 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
1468 {
1469 6575 bool kb = false;
1470 6575 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1471
1472
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 6575 times.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6575 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6575 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6575 times.
6575 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1473 return true;
1474
1475
2/2
✓ Branch 0 taken 5062 times.
✓ Branch 1 taken 1513 times.
6575 if(isdungeon(screen_spawned))
1476 {
1477
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dy<32) || (dy>=world_h-32))
1478 return true;
1479
1480
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dx<32) || (dx>=world_w-32))
1481 return true;
1482 1513 }
1483
1484
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
6575 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall))) //Don't walk into pits, unless being knocked back
1485 {
1486
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
13150 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1487
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
6575 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1488 return true;
1489 6575 }
1490
1491
2/2
✓ Branch 0 taken 6545 times.
✓ Branch 1 taken 30 times.
6575 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1492 {
1493
3/4
✓ Branch 0 taken 2657 times.
✓ Branch 1 taken 3888 times.
✓ Branch 2 taken 2657 times.
✗ Branch 3 not taken.
9202 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2657 times.
2657 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1495 }
1496 else
1497 {
1498
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
60 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1499
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1500
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1502 }
1503 6575 }
1504
1505 // returns true if cannot walk
1506 32505729 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
1507 {
1508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32505729 times.
32505729 if(moveflags & move_new_movement)
1509 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
1510 32505729 int32_t yg = (special==spw_floater)?8:0;
1511 32505729 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1512
2/2
✓ Branch 0 taken 3724406 times.
✓ Branch 1 taken 28781323 times.
32505729 switch(dir)
1513 {
1514 case l_down:
1515 case r_down:
1516 case down:
1517 case 11: //r_down
1518 case 12: //down
1519 case 13: //l_down
1520 {
1521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3724406 times.
3724406 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1522 {
1523
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3724398 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
3724406 if ( SIZEflags&OVERRIDE_HIT_HEIGHT && !isflier(id) )
1524 {
1525 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1526
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 dy += zc_max(hit_height-16,0);
1527 8 }
1528 3724406 }
1529 3724406 break;
1530 }
1531 }
1532
2/2
✓ Branch 0 taken 3726357 times.
✓ Branch 1 taken 28779372 times.
32505729 switch(dir)
1533 {
1534 case r_up:
1535 case r_down:
1536 case right:
1537 case 9: //r_up
1538 case 10: //right
1539 case 11: //r_down
1540 {
1541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3726357 times.
3726357 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1542 {
1543
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3726354 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3726357 if ( SIZEflags&OVERRIDE_HIT_WIDTH && !isflier(id) )
1544 {
1545 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1546
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dx += zc_max(hit_width-16,0);
1547 3 }
1548 3726357 }
1549 3726357 break;
1550 }
1551 }
1552
1553
10/10
✓ Branch 0 taken 22401875 times.
✓ Branch 1 taken 10103854 times.
✓ Branch 2 taken 8754457 times.
✓ Branch 3 taken 1349397 times.
✓ Branch 4 taken 10066678 times.
✓ Branch 5 taken 37176 times.
✓ Branch 6 taken 10043475 times.
✓ Branch 7 taken 23203 times.
✓ Branch 8 taken 22454867 times.
✓ Branch 9 taken 32498342 times.
32505729 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1554 44917121 return true;
1555
1556 32498342 bool isInDungeon = isdungeon(screen_spawned);
1557
4/4
✓ Branch 0 taken 3976583 times.
✓ Branch 1 taken 28521759 times.
✓ Branch 2 taken 11756 times.
✓ Branch 3 taken 3964827 times.
32498342 if(isInDungeon || special==spw_wizzrobe)
1558 {
1559
8/8
✓ Branch 0 taken 5892236 times.
✓ Branch 1 taken 22641279 times.
✓ Branch 2 taken 5667745 times.
✓ Branch 3 taken 224491 times.
✓ Branch 4 taken 5820349 times.
✓ Branch 5 taken 17045421 times.
✓ Branch 6 taken 5820162 times.
✓ Branch 7 taken 187 times.
28533515 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=world_h-32 && dy>=world_h-32))
1560 11487907 return true;
1561
1562
8/8
✓ Branch 0 taken 5739852 times.
✓ Branch 1 taken 11305756 times.
✓ Branch 2 taken 5573332 times.
✓ Branch 3 taken 166520 times.
✓ Branch 4 taken 5688285 times.
✓ Branch 5 taken 5783991 times.
✓ Branch 6 taken 5687331 times.
✓ Branch 7 taken 954 times.
17045608 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<world_w-32 && dx>=world_w-32))
1563
2/2
✓ Branch 0 taken 113905 times.
✓ Branch 1 taken 94 times.
11260663 if(special!=spw_door) // walk in door way
1564 113905 return true;
1565 5785039 }
1566
1567
6/6
✓ Branch 0 taken 3102356 times.
✓ Branch 1 taken 6647510 times.
✓ Branch 2 taken 750728 times.
✓ Branch 3 taken 2351628 times.
✓ Branch 4 taken 51230 times.
✓ Branch 5 taken 699498 times.
9749866 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
1568 {
1569
4/4
✓ Branch 0 taken 3044709 times.
✓ Branch 1 taken 6417 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 3043757 times.
6094933 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1570
4/4
✓ Branch 0 taken 3044526 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 3043807 times.
✓ Branch 3 taken 719 times.
3044709 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1571 7369 return true;
1572 3043757 }
1573
1574
4/4
✓ Branch 0 taken 7555697 times.
✓ Branch 1 taken 2180546 times.
✓ Branch 2 taken 973 times.
✓ Branch 3 taken 5281 times.
9742497 switch(special)
1575 {
1576 case spw_clipbottomright:
1577
4/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 187 times.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 707 times.
973 if(dy>=world_h-48 || dx>=world_w-48) return true;
1578 707 break;
1579 case spw_clipright:
1580 5281 break; //if(input_x>=208) return true; break;
1581
1582 case spw_wizzrobe: // fall through
1583 case spw_floater: // Special case for fliers and wizzrobes - hack!
1584 {
1585
2/2
✓ Branch 0 taken 2914018 times.
✓ Branch 1 taken 4641679 times.
7555697 if(isInDungeon)
1586 {
1587
3/4
✓ Branch 0 taken 4641667 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4641667 times.
4641679 if(dy < 32-yg || dy >= world_h-32) return true;
1588
4/4
✓ Branch 0 taken 4639555 times.
✓ Branch 1 taken 2112 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4639539 times.
4641667 if(dx < 32 || dx >= world_w-32) return true;
1589 4639539 }
1590 7553557 return false;
1591 }
1592 }
1593
1594 2186534 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1595
2/2
✓ Branch 0 taken 486589 times.
✓ Branch 1 taken 1699945 times.
2186534 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1596
1597
2/2
✓ Branch 0 taken 414677 times.
✓ Branch 1 taken 1771857 times.
2186534 if(special==spw_water)
1598
2/2
✓ Branch 0 taken 16749 times.
✓ Branch 1 taken 397928 times.
414677 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1599
1600
2/2
✓ Branch 0 taken 1711908 times.
✓ Branch 1 taken 59949 times.
1771857 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1601 {
1602
4/4
✓ Branch 0 taken 1228217 times.
✓ Branch 1 taken 483691 times.
✓ Branch 2 taken 1218180 times.
✓ Branch 3 taken 10037 times.
2930088 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1603
2/2
✓ Branch 0 taken 14580 times.
✓ Branch 1 taken 1203600 times.
1218180 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1604 }
1605 else
1606 {
1607
4/4
✓ Branch 0 taken 42909 times.
✓ Branch 1 taken 17040 times.
✓ Branch 2 taken 42645 times.
✓ Branch 3 taken 264 times.
102594 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1608
3/4
✓ Branch 0 taken 42282 times.
✓ Branch 1 taken 363 times.
✓ Branch 2 taken 42282 times.
✗ Branch 3 not taken.
42645 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1609
4/4
✓ Branch 0 taken 37047 times.
✓ Branch 1 taken 5235 times.
✓ Branch 2 taken 37032 times.
✓ Branch 3 taken 15 times.
42282 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1610
2/2
✓ Branch 0 taken 36729 times.
✓ Branch 1 taken 303 times.
37032 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1611 }
1612 10129559 }
1613
1614 496901 bool enemy::isOnSideviewPlatform()
1615 {
1616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
1617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
1618
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
496901 if(!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)&&fall<0)
1619 return false;
1620
5/6
✓ Branch 0 taken 11630 times.
✓ Branch 1 taken 485271 times.
✓ Branch 2 taken 422 times.
✓ Branch 3 taken 11208 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 422 times.
496901 if(y + usehei >= world_h && cur_screen>=0x70 && !(get_scr_for_world_xy(x, y)->flags2&wfDOWN)) return true; //Bottom of the map
1621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496479 times.
496479 if(check_slope(x, y+1, usewid, usehei)) return true;
1622
2/2
✓ Branch 0 taken 496479 times.
✓ Branch 1 taken 215641 times.
712120 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
1623 {
1624
2/2
✓ Branch 0 taken 215641 times.
✓ Branch 1 taken 280838 times.
496479 if(_walkflag(nx,y+usehei,1)) return true;
1625
3/4
✓ Branch 0 taken 215641 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 151313 times.
✓ Branch 3 taken 64328 times.
215641 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
1626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64328 times.
64328 if(checkSVLadderPlatform(nx,y+usehei)) return true;
1627 64328 }
1628 215641 return false;
1629 496901 }
1630
1631 // Stops playing the given sound only if there are no enemies left to play it
1632 768489 void enemy::stop_bgsfx(int32_t index)
1633 {
1634
2/2
✓ Branch 0 taken 753379 times.
✓ Branch 1 taken 15110 times.
768489 if(bgsfx<=0)
1635 753379 return;
1636
1637 // Look for other enemies with the same bgsfx
1638
2/2
✓ Branch 0 taken 52994 times.
✓ Branch 1 taken 8806 times.
61800 for(int32_t i=0; i<guys.Count(); i++)
1639 {
1640
4/4
✓ Branch 0 taken 41902 times.
✓ Branch 1 taken 11092 times.
✓ Branch 2 taken 6304 times.
✓ Branch 3 taken 35598 times.
52994 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
1641 6304 return;
1642 46690 }
1643
1644 8806 stop_sfx(bgsfx);
1645 768489 }
1646
1647
1648 // to allow for different sfx on defeating enemy
1649 40356 void enemy::death_sfx()
1650 {
1651
2/2
✓ Branch 0 taken 40071 times.
✓ Branch 1 taken 285 times.
40356 if(deadsfx > 0) sfx(deadsfx,pan(x));
1652 40356 }
1653
1654 void enemy::move(zfix dx,zfix dy)
1655 {
1656 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & move_obeys_grav) || !enemycanfall(id)))
1657 {
1658 x+=dx;
1659 y+=dy;
1660 }
1661 }
1662
1663 18374579 void enemy::move(zfix s)
1664 {
1665
9/10
✓ Branch 0 taken 18374540 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 109109 times.
✓ Branch 3 taken 18265431 times.
✓ Branch 4 taken 58221 times.
✓ Branch 5 taken 50888 times.
✓ Branch 6 taken 1005 times.
✓ Branch 7 taken 57216 times.
✓ Branch 8 taken 1005 times.
✗ Branch 9 not taken.
18374579 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & move_obeys_grav)))
1666 {
1667 18373535 sprite::move(s);
1668 18373535 }
1669 18374579 }
1670
1671 43836 void enemy::leave_item()
1672 {
1673 43836 int32_t drop_item = select_dropitem(item_set, x, y);
1674 43836 int32_t thedropset = item_set;
1675
1676 43836 std::vector<int32_t> &ev = FFCore.eventData;
1677 43836 ev.clear();
1678 43836 ev.push_back(getUID());
1679 43836 ev.push_back(drop_item*10000);
1680 43836 ev.push_back(thedropset*10000);
1681
1682 43836 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
1683 43836 drop_item = vbound(ev[1] / 10000,-2,255);
1684 43836 thedropset = ev[2] / 10000;
1685 43836 ev.clear();
1686
1/2
✓ Branch 0 taken 43836 times.
✗ Branch 1 not taken.
43836 if(drop_item == -2)
1687 {
1688 drop_item = select_dropitem(thedropset,x,y);
1689 }
1690
1691
6/6
✓ Branch 0 taken 16545 times.
✓ Branch 1 taken 27291 times.
✓ Branch 2 taken 917 times.
✓ Branch 3 taken 15628 times.
✓ Branch 4 taken 169 times.
✓ Branch 5 taken 748 times.
43836 if(drop_item>=0&&((itemsbuf[drop_item].type!=itype_fairy)||!m_walkflag(x,y,0,dir)))
1692 {
1693 item* itm;
1694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16376 times.
16376 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
1695 {
1696 itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1697 }
1698 else
1699 {
1700
8/14
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 14656 times.
✓ Branch 2 taken 1720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1720 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1720 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1720 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1720 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1720 times.
✗ Branch 13 not taken.
16376 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1701
4/8
✓ Branch 0 taken 14656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14656 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14656 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14656 times.
✗ Branch 7 not taken.
14656 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1702 }
1703 16376 itm->from_dropset = thedropset;
1704 16376 add_item_for_screen(screen_spawned, itm);
1705
1706 16376 ev.push_back(getUID());
1707 16376 ev.push_back(itm->getUID());
1708
1709 16376 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
1710 16376 ev.clear();
1711 16376 }
1712 43836 }
1713
1714 // auomatically kill off enemy (for rooms with ringleaders)
1715 411 void enemy::kickbucket()
1716 {
1717
3/4
✓ Branch 0 taken 379 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 379 times.
✗ Branch 3 not taken.
411 if(!superman && !(flags&guy_ignore_kill_all))
1718 379 hp=-1000; // don't call death_sfx()
1719 411 }
1720
1721 21250 bool enemy::isSubmerged() const
1722 {
1723 21250 return submerged;
1724 //!TODO SOLIDPUSH more things like teleporting wizzrobes
1725 }
1726
1727 20952 void enemy::FireBreath(bool seekhero)
1728 {
1729
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if(wpn==wNone)
1730 return;
1731
1732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20952 times.
20952 if(wpn==ewFireTrail)
1733 {
1734 dmisc1 = e1tEACHTILE;
1735 FireWeapon();
1736 return;
1737 }
1738
1739 20952 float fire_angle=0.0;
1740 20952 int32_t wx=0, wy=0, wdir=dir, xoff=0, yoff=0;
1741
1742
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1743 {
1744 xoff += hxofs;
1745 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
1746 xoff += (hit_width / 2) - (weap_data.tilew * 8);
1747 else
1748 xoff += (hit_width / 2) - 8;
1749 }
1750
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1751 {
1752 yoff += hyofs;
1753 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
1754 yoff += (hit_height / 2) - (weap_data.tileh * 8);
1755 else
1756 yoff += (hit_height / 2) - 8;
1757 }
1758
1759
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 if(!seekhero)
1760 {
1761
4/5
✓ Branch 0 taken 3297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3079 times.
✓ Branch 3 taken 5287 times.
✓ Branch 4 taken 4208 times.
15871 switch(dir)
1762 {
1763 case down:
1764 3079 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
1765 3079 wx=x;
1766 3079 wy=y+8;
1767 3079 break;
1768
1769 case -1:
1770 case up:
1771 3297 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
1772 3297 wx=x;
1773 3297 wy=y-8;
1774 3297 break;
1775
1776 case left:
1777 5287 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
1778 5287 wx=x-8;
1779 5287 wy=y;
1780 5287 break;
1781
1782 case right:
1783 4208 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
1784 4208 wx=x+8;
1785 4208 wy=y;
1786 4208 break;
1787 }
1788
1789
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 15735 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
15871 if(wpn==ewFlame || wpn==ewFlame2)
1790 {
1791
2/4
✓ Branch 0 taken 15735 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15735 times.
15735 if(fire_angle==-PI || fire_angle==PI) wdir=left;
1792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==-PI/2) wdir=up;
1793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==PI/2) wdir=down;
1794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==0) wdir=right;
1795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<-PI/2) wdir=l_up;
1796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<0) wdir=r_up;
1797
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14237 times.
15735 else if(fire_angle<(PI/2)) wdir=r_down;
1798
2/2
✓ Branch 0 taken 10121 times.
✓ Branch 1 taken 4116 times.
14237 else if(fire_angle<PI) wdir=l_down;
1799 15735 }
1800 15871 }
1801 else
1802 {
1803 5081 wx = x;
1804 5081 wy = y;
1805 }
1806
1807
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 addEwpn(wx+xoff,wy+yoff,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
1808 20952 sfx(wpnsfx(wpn),pan(x));
1809
1810 20952 int32_t i=Ewpns.Count()-1;
1811 20952 weapon *ew = (weapon*)(Ewpns.spr(i));
1812 20952 ew->moveflags &= ~move_can_pitfall; //No falling in pits
1813
1814
4/4
✓ Branch 0 taken 15871 times.
✓ Branch 1 taken 5081 times.
✓ Branch 2 taken 7914 times.
✓ Branch 3 taken 7957 times.
20952 if(!seekhero && (zc_oldrand()&4))
1815 {
1816 7957 ew->angular=true;
1817 7957 ew->angle=fire_angle;
1818 7957 }
1819
1820
4/4
✓ Branch 0 taken 20676 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 20359 times.
20952 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
1821 {
1822 20359 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
1823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20359 times.
20359 if ( ew->do_animation ) ew->tile+=ew->aframe;
1824 20359 }
1825
1826
2/2
✓ Branch 0 taken 20952 times.
✓ Branch 1 taken 766199 times.
787151 for(int32_t j=Ewpns.Count()-1; j>0; j--)
1827 {
1828 766199 Ewpns.swap(j,j-1);
1829 766199 }
1830 20952 }
1831
1832 44662 void enemy::FireWeapon()
1833 {
1834 /*
1835 * Type:
1836 * 0x01: Boss fireball
1837 * 0x02: Seeks Hero
1838 * 0x04: Fast projectile
1839 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
1840 */
1841
1842
2/2
✓ Branch 0 taken 44531 times.
✓ Branch 1 taken 131 times.
44662 if (wpn < 1) return;
1843
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 44531 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
44531 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
1844 return;
1845
1846
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44531 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
44531 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
1847 dmisc1 = e1tEACHTILE;
1848
1849 44531 int32_t xoff = 0;
1850 44531 int32_t yoff = 0;
1851
1/2
✓ Branch 0 taken 44531 times.
✗ Branch 1 not taken.
44531 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1852 {
1853 xoff += hxofs;
1854 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
1855 xoff += (hit_width / 2) - (weap_data.tilew * 8);
1856 else
1857 xoff += (hit_width / 2) - 8;
1858 }
1859
1/2
✓ Branch 0 taken 44531 times.
✗ Branch 1 not taken.
44531 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1860 {
1861 yoff += hyofs;
1862 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
1863 yoff += (hit_height / 2) - (weap_data.tileh * 8);
1864 else
1865 yoff += (hit_height / 2) - 8;
1866 }
1867
1868 // TODO(crash): check that .add succeeds.
1869
1870
5/8
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 41532 times.
✓ Branch 2 taken 1839 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 416 times.
✓ Branch 5 taken 98 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
44531 switch(dmisc1)
1871 {
1872 case e1t5SHOTS: //BS-Aquamentus
1873 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
1874 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1875 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
1876 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1877
1878 [[fallthrough]];
1879 case e1t3SHOTSFAST:
1880 case e1t3SHOTS: //Aquamentus
1881
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1882 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1883
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1884 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1885
1886 [[fallthrough]];
1887 default:
1888
12/20
✓ Branch 0 taken 42178 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42178 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42178 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42178 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 42178 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 42173 times.
✓ Branch 12 taken 42178 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18238 times.
✓ Branch 15 taken 23940 times.
✓ Branch 16 taken 42178 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 42178 times.
✗ Branch 19 not taken.
42178 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1889 42178 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1890 42178 sfx(wpnsfx(wpn),pan(x));
1891 42178 break;
1892
1893 case e1tSLANT:
1894 {
1895 416 int32_t slant = 0;
1896
1897
10/10
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 216 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 161 times.
✓ Branch 6 taken 61 times.
✓ Branch 7 taken 316 times.
✓ Branch 8 taken 138 times.
✓ Branch 9 taken 178 times.
416 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
1898 246 slant = left;
1899
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 33 times.
✓ Branch 6 taken 55 times.
✓ Branch 7 taken 86 times.
✓ Branch 8 taken 25 times.
✓ Branch 9 taken 61 times.
178 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
1900 117 slant = right;
1901
1902
9/18
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 330 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 330 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 330 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 330 times.
✓ Branch 14 taken 330 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 330 times.
✗ Branch 17 not taken.
330 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1903 330 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1904 330 sfx(wpnsfx(wpn),pan(x));
1905 330 break;
1906 }
1907
1908 case e1t8SHOTS: //Fire Wizzrobe
1909
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
1910 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1911 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1912
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
1913 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1914 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1915
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
1916 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1917 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1918
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
1919 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1920 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1921
1922 [[fallthrough]];
1923 case e1t4SHOTS: //Stalfos 3
1924
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
1925 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1926 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1927
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
1928 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1929 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1930
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
1931 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1932 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1933
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
1934 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1935 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1936 1937 sfx(wpnsfx(wpn),pan(x));
1937 1937 break;
1938
1939 case e1tSUMMON: // Bat Wizzrobe
1940 {
1941 if(dmisc4==0) break; // Summon 0
1942
1943 int32_t bc=0;
1944
1945 for(int32_t gc=0; gc<guys.Count(); gc++)
1946 {
1947 if((((enemy*)guys.spr(gc))->id) == dmisc3)
1948 {
1949 ++bc;
1950 }
1951 }
1952
1953 if(bc<=40) // Not too many enemies
1954 {
1955 int32_t kids = guys.Count();
1956 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
1957
1958 for(int32_t i=0; i<bats; i++)
1959 {
1960 if(addchild(screen_spawned,x,y,dmisc3,-10, this))
1961 {
1962 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1963 }
1964 }
1965
1966 sfx(firesfx, pan(x));
1967 }
1968
1969 break;
1970 }
1971
1972 case e1tSUMMONLAYER: // Summoner
1973 {
1974 if(count_layer_enemies(screen_spawned)==0)
1975 {
1976 break;
1977 }
1978
1979 int32_t kids = guys.Count();
1980
1981 if(kids<40)
1982 {
1983 int32_t newguys=(zc_oldrand()%3)+1;
1984 bool summoned=false;
1985
1986 for(int32_t i=0; i<newguys; i++)
1987 {
1988 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
1989 int32_t x2=0;
1990 int32_t y2=0;
1991
1992 for(int32_t k=0; k<20; ++k)
1993 {
1994 x2=16*((zc_oldrand()%12)+2);
1995 y2=16*((zc_oldrand()%7)+2);
1996
1997 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
1998 {
1999 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this))
2000 {
2001 ((enemy*)guys.spr(kids+i))->count_enemy = false;
2002 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
2003 {
2004 ((enemy*)guys.spr(kids+i))->fakez = 64;
2005 ((enemy*)guys.spr(kids+i))->z = 0;
2006 }
2007 }
2008
2009 summoned=true;
2010 break;
2011 }
2012 }
2013 }
2014
2015 if(summoned)
2016 {
2017 sfx(firesfx, pan(x));
2018 }
2019 }
2020
2021 break;
2022 }
2023 }
2024 44576 }
2025
2026
2027 // Hit the shield(s)?
2028 // Apparently, this function is only used for hookshots...
2029 2767 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
2030 {
2031
6/6
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 1791 times.
✓ Branch 2 taken 975 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 141 times.
✓ Branch 5 taken 834 times.
2767 if(!(type==eeWALK || type==eeFIRE || type==eeOTHER))
2032 834 return false;
2033
2034 1933 bool ret = false;
2035
2036 // TODO: There must be some bitwise operations that can simplify this...
2037
9/12
✓ Branch 0 taken 1207 times.
✓ Branch 1 taken 726 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 683 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 699 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 699 times.
✓ Branch 10 taken 699 times.
✗ Branch 11 not taken.
1933 if(wpny > y) ret = ((flags&guy_shield_front && xdir==down) || (flags&guy_shield_back && xdir==up) || (flags&guy_shield_left && xdir==left) || (flags&guy_shield_right && xdir==right));
2038
9/12
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 824 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 778 times.
✓ Branch 4 taken 33 times.
✓ Branch 5 taken 13 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 811 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 811 times.
✓ Branch 10 taken 811 times.
✗ Branch 11 not taken.
1207 else if(wpny < y) ret = ((flags&guy_shield_front && xdir==up) || (flags&guy_shield_back && xdir==down) || (flags&guy_shield_left && xdir==right) || (flags&guy_shield_right && xdir==left));
2039
2040
11/14
✓ Branch 0 taken 1065 times.
✓ Branch 1 taken 868 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 849 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 825 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 840 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 840 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 840 times.
1933 if(wpnx < x) ret = ret || ((flags&guy_shield_front && xdir==left) || (flags&guy_shield_back && xdir==right) || (flags&guy_shield_left && xdir==down) || (flags&guy_shield_right && xdir==up));
2041
11/14
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 876 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 863 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 827 times.
✓ Branch 6 taken 19 times.
✓ Branch 7 taken 17 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 844 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 844 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 844 times.
1065 else if(wpnx > x) ret = ret || ((flags&guy_shield_front && xdir==right) || (flags&guy_shield_back && xdir==left) || (flags&guy_shield_left && xdir==up) || (flags&guy_shield_right && xdir==down));
2042
2043 1933 return ret;
2044 2767 }
2045
2046
2047 //! Weapon Editor for 2.6
2048 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
2049
2050
2051 //converts a wqeapon ID to its defence index.
2052 127485 int32_t weaponToDefence(int32_t wid)
2053 {
2054
23/47
✗ Branch 0 not taken.
✓ Branch 1 taken 64772 times.
✓ Branch 2 taken 9439 times.
✓ Branch 3 taken 25035 times.
✓ Branch 4 taken 4210 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 48 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3160 times.
✓ Branch 9 taken 9836 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 269 times.
✓ Branch 13 taken 1438 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 512 times.
✓ Branch 17 taken 1459 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2054 times.
✓ Branch 20 taken 2767 times.
✓ Branch 21 taken 610 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 240 times.
✓ Branch 24 taken 469 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 19 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 28 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 12 times.
✓ Branch 33 taken 77 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✓ Branch 39 taken 993 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✓ Branch 42 taken 1 times.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
127485 switch(wid)
2055 {
2056 case wNone: return -1;
2057 64772 case wSword: return edefSWORD;
2058 9439 case wBeam: return edefBEAM;
2059 25035 case wBrang: return edefBRANG;
2060 4210 case wBomb: return edefBOMB;
2061 37 case wSBomb: return edefSBOMB;
2062 48 case wLitBomb: return edefBOMB;
2063 case wLitSBomb: return edefSBOMB;
2064 3160 case wArrow: return edefARROW;
2065 9836 case wFire: return edefFIRE;
2066 case wWhistle:
2067 {
2068 return edefWhistle;
2069 }
2070 case wBait: return edefBAIT;
2071 269 case wWand: return edefWAND;
2072 1438 case wMagic: return edefMAGIC;
2073 case wCatching: return -1;
2074 case wWind: return edefWIND;
2075 512 case wRefMagic: return edefREFMAGIC;
2076 1459 case wRefFireball: return edefREFBALL;
2077 case wRefRock: return edefREFROCK;
2078 2054 case wHammer: return edefHAMMER;
2079 2767 case wHookshot: return edefHOOKSHOT;
2080 610 case wHSHandle: return edefHOOKSHOT;
2081 case wHSChain: return edefHOOKSHOT;
2082 240 case wSSparkle: return edefSPARKLE;
2083 469 case wFSparkle: return edefSPARKLE;
2084 case wSmack: return -1; // is this the candle object?
2085 case wPhantom: return -1; //engine created visual effects.
2086 case wCByrna: return edefBYRNA;
2087 19 case wRefBeam: return edefREFBEAM;
2088 case wStomp: return edefSTOMP;
2089 28 case wScript1: return edefSCRIPT01;
2090 case wScript2: return edefSCRIPT02;
2091 12 case wScript3: return edefSCRIPT03;
2092 77 case wScript4: return edefSCRIPT04;
2093 case wScript5: return edefSCRIPT05;
2094 case wScript6: return edefSCRIPT06;
2095 case wScript7: return edefSCRIPT07;
2096 case wScript8: return edefSCRIPT08;
2097 case wScript9: return edefSCRIPT09;
2098 993 case wScript10: return edefSCRIPT10;
2099 case wIce: return edefICE;
2100 case wSound: return edefSONIC;
2101 1 case wThrown: return edefTHROWN;
2102 case wRefArrow: return edefREFARROW;
2103 case wRefFire: return edefREFFIRE;
2104 case wRefFire2: return edefREFFIRE2;
2105 //case wPot: return edefPOT;
2106 // case wLitZap: return edefELECTRIC;
2107 // case wZ3Sword: return edefZ3SWORD;
2108 // case wLASWord: return edefLASWORD;
2109 // case wSpinAttk: return edefSPINATTK;
2110 // case wShield: return edefSHIELD;
2111 // case wTrowel: return edefTROWEL;
2112
2113 default: return -1;
2114 }
2115 127485 }
2116
2117 127485 int32_t getDefType(weapon *w)
2118 {
2119 127485 int32_t id = getWeaponID(w);
2120 127485 int32_t edef = weaponToDefence(id);
2121
2/2
✓ Branch 0 taken 124108 times.
✓ Branch 1 taken 3377 times.
127485 if(edef == edefHOOKSHOT)
2122 {
2123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3377 times.
3377 if(w->family_class == itype_switchhook)
2124 return edefSwitchHook;
2125 3377 }
2126 127485 return edef;
2127 127485 }
2128
2129 227168 int32_t getWeaponID(weapon *w)
2130 {
2131 227168 int32_t usewpn = w->useweapon;
2132
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 226938 times.
227168 return (usewpn > 0) ? usewpn : w->id;
2133 }
2134
2135 127485 int32_t enemy::resolveEnemyDefence(weapon *w)
2136 {
2137 //sword edef is 9, but we're reading it at 0
2138 //,
2139 127485 int32_t weapondef = 0;
2140 127485 int32_t wdeftype = getDefType(w);
2141 127485 int32_t usedef = w->usedefense;
2142
2143
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 127485 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
127485 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
2144 {
2145 weapondef = usedef*-1;
2146 }
2147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127485 times.
127485 else if(unsigned(wdeftype) < edefLAST255)
2148 {
2149 127485 weapondef = wdeftype;
2150 127485 }
2151 127485 return weapondef;
2152 }
2153
2154 138054 byte get_def_ignrflag(int32_t edef)
2155 {
2156
3/3
✓ Branch 0 taken 115084 times.
✓ Branch 1 taken 3683 times.
✓ Branch 2 taken 19287 times.
138054 switch(edef)
2157 {
2158 case edIGNORE:
2159 case edIGNOREL1:
2160 case edSTUNORIGNORE:
2161 19287 return WPNUNB_IGNR;
2162 case edSTUNORCHINK:
2163 case edCHINK:
2164 case edCHINKL1:
2165 case edCHINKL2:
2166 case edCHINKL4:
2167 case edCHINKL6:
2168 case edCHINKL8:
2169 case edCHINKL10:
2170 case edLEVELCHINK2:
2171 case edLEVELCHINK3:
2172 case edLEVELCHINK4:
2173 case edLEVELCHINK5:
2174 3683 return WPNUNB_BLOCK;
2175 }
2176 115084 return 0;
2177 138054 }
2178
2179 138054 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
2180 {
2181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138054 times.
138054 if(!(unblockable&get_def_ignrflag(edef))) return edef;
2182 switch(edef)
2183 {
2184 case edIGNORE:
2185 case edIGNOREL1:
2186 case edCHINK:
2187 case edCHINKL1:
2188 case edCHINKL2:
2189 case edCHINKL4:
2190 case edCHINKL6:
2191 case edCHINKL8:
2192 case edCHINKL10:
2193 case edLEVELCHINK2:
2194 case edLEVELCHINK3:
2195 case edLEVELCHINK4:
2196 case edLEVELCHINK5:
2197 return edNORMAL;
2198 case edSTUNORIGNORE:
2199 case edSTUNORCHINK:
2200 return edSTUNONLY;
2201 }
2202 return edef;
2203 138054 }
2204
2205 // Do we do damage?
2206 // 0: takehit returns 0
2207 // 1: takehit returns 1
2208 // -1: do damage
2209 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
2210 126492 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
2211 {
2212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126492 times.
126492 if(switch_hooked) return 0;
2213 126492 int32_t tempx = x;
2214 126492 int32_t tempy = y;
2215 126492 int32_t the_defence = 0;
2216
1/2
✓ Branch 0 taken 126492 times.
✗ Branch 1 not taken.
126492 if ( edef < 0 ) //we are using a specific base default defence for a weapon
2217 {
2218 the_defence = edef*-1; //A specific defence type.
2219 }
2220 126492 else the_defence = defense[edef];
2221
2222 126492 the_defence = conv_edef_unblockable(the_defence, unblockable);
2223
2224
3/4
✓ Branch 0 taken 6623 times.
✓ Branch 1 taken 119869 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6623 times.
126492 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
2225 {
2226
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6616 times.
✓ Branch 2 taken 7 times.
6623 switch(the_defence)
2227 {
2228 case edIGNORE:
2229 7 return 0;
2230 case edIGNOREL1:
2231 case edSTUNORIGNORE:
2232 if(*power <= 0)
2233 return 0;
2234 }
2235 6616 sfx(WAV_CHINK,pan(x));
2236 6616 return 1;
2237 }
2238
2239 119869 int32_t new_id = id;
2240 119869 int32_t effect_type = dmisc15;
2241 119869 int32_t delay_timer = 90;
2242 119869 enemy *gleeok = NULL;
2243 119869 enemy *ptra = NULL;
2244 119869 int32_t c = 0;
2245
2246
16/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 492 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1931 times.
✓ Branch 6 taken 1862 times.
✓ Branch 7 taken 113 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 43 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 945 times.
✓ Branch 13 taken 17349 times.
✓ Branch 14 taken 883 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 2175 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 158 times.
✓ Branch 26 taken 105 times.
✓ Branch 27 taken 4 times.
✓ Branch 28 taken 93608 times.
119869 switch(the_defence)
2247 {
2248 case edREPLACE:
2249 {
2250 sclk = 0;
2251 if ( dmisc16 > 0 ) new_id = dmisc16;
2252 else new_id = id+1;
2253 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
2254 if ( dmisc17 > 0 ) delay_timer = dmisc17;
2255 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
2256
2257 //Z_scripterrlog("new id is %d\n", new_id);
2258 switch(guysbuf[new_id&0xFFF].type)
2259 {
2260 //Fixme: possible enemy memory leak. (minor)
2261 case eeWALK:
2262 {
2263 enemy *e = new eStalfos(x,y,new_id,clk);
2264 guys.add(e);
2265 }
2266 break;
2267
2268 case eeLEV:
2269 {
2270 enemy *e = new eLeever(x,y,new_id,clk);
2271 guys.add(e);
2272 }
2273 break;
2274
2275 case eeTEK:
2276 {
2277 enemy *e = new eTektite(x,y,new_id,clk);
2278 guys.add(e);
2279 }
2280 break;
2281
2282 case eePEAHAT:
2283 {
2284 enemy *e = new ePeahat(x,y,new_id,clk);
2285 guys.add(e);
2286 }
2287 break;
2288
2289 case eeZORA:
2290 {
2291 enemy *e = new eZora(x,y,new_id,clk);
2292 guys.add(e);
2293 }
2294 break;
2295
2296 case eeGHINI:
2297 {
2298 enemy *e = new eGhini(x,y,new_id,clk);
2299 guys.add(e);
2300 }
2301 break;
2302
2303 case eeKEESE:
2304 {
2305 enemy *e = new eKeese(x,y,new_id,clk);
2306 guys.add(e);
2307 }
2308 break;
2309
2310 case eeWIZZ:
2311 {
2312 enemy *e = new eWizzrobe(x,y,new_id,clk);
2313 guys.add(e);
2314 }
2315 break;
2316
2317 case eePROJECTILE:
2318 {
2319 enemy *e = new eProjectile(x,y,new_id,clk);
2320 guys.add(e);
2321 }
2322 break;
2323
2324 case eeWALLM:
2325 {
2326 enemy *e = new eWallM(x,y,new_id,clk);
2327 guys.add(e);
2328 }
2329 break;
2330
2331 case eeAQUA:
2332 {
2333 enemy *e = new eAquamentus(x,y,new_id,clk);
2334 guys.add(e);
2335 e->x = x;
2336 e->y = y;
2337 }
2338 break;
2339
2340 case eeMOLD:
2341 {
2342 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0])));
2343 guys.add(e);
2344 e->x = x;
2345 e->y = y;
2346 }
2347 break;
2348
2349 case eeMANHAN:
2350 {
2351 enemy *e = new eManhandla(x,y,new_id,clk);
2352 guys.add(e);
2353 e->x = x;
2354 e->y = y;
2355 }
2356 break;
2357
2358 case eeGLEEOK:
2359 {
2360 *power = 0;
2361 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].attributes[0]);
2362 guys.add(gleeok);
2363 // TODO(crash): check that .add succeeds.
2364 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2365 new_id &= 0xFFF;
2366 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2367 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2368 for(int32_t i=0; i<head_cnt; i++)
2369 {
2370 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2371 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2372 {
2373 al_trace("Gleeok head %d could not be created!\n",i+1);
2374
2375 for(int32_t j=0; j<i+1; j++)
2376 {
2377 guys.del(guys.Count()-1);
2378 }
2379
2380 break;
2381 }
2382 else
2383 {
2384 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2385 }
2386
2387 c-=guysbuf[new_id].attributes[3];
2388 }
2389 return 1;
2390 }
2391
2392 case eeGHOMA:
2393 {
2394 enemy *e = new eGohma(x,y,new_id,clk);
2395 guys.add(e);
2396 e->x = x;
2397 e->y = y;
2398 }
2399 break;
2400
2401 case eeLANM:
2402 {
2403 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])));
2404 guys.add(e);
2405 e->x = x;
2406 e->y = y;
2407 }
2408 break;
2409
2410 case eeGANON:
2411 {
2412 enemy *e = new eGanon(x,y,new_id,clk);
2413 guys.add(e);
2414 e->x = x;
2415 e->y = y;
2416 }
2417 break;
2418
2419 case eeFAIRY:
2420 {
2421 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
2422 guys.add(e);
2423 e->x = x;
2424 e->y = y;
2425 }
2426 break;
2427
2428 case eeFIRE:
2429 {
2430 enemy *e = new eFire(x,y,new_id,clk);
2431 guys.add(e);
2432 e->x = x;
2433 e->y = y;
2434 }
2435 break;
2436
2437 case eeOTHER:
2438 {
2439 enemy *e = new eOther(x,y,new_id,clk);
2440 guys.add(e);
2441 e->x = x;
2442 e->y = y;
2443 }
2444 break;
2445
2446 case eeSPINTILE:
2447 {
2448 enemy *e = new eSpinTile(x,y,new_id,clk);
2449 guys.add(e);
2450 e->x = x;
2451 e->y = y;
2452 }
2453 break;
2454
2455 // and these enemies use the misc10/misc2 value
2456 case eeROCK:
2457 {
2458 switch(guysbuf[new_id&0xFFF].attributes[9])
2459 {
2460 case 1:
2461 {
2462 enemy *e = new eBoulder(x,y,new_id,clk);
2463 guys.add(e);
2464 e->x = x;
2465 e->y = y;
2466 }
2467 break;
2468
2469 case 0:
2470 default:
2471 {
2472 enemy *e = new eRock(x,y,new_id,clk);
2473 guys.add(e);
2474 e->x = x;
2475 e->y = y;
2476 }
2477 break;
2478 }
2479
2480 break;
2481 }
2482
2483 case eeTRAP:
2484 {
2485 switch(guysbuf[new_id&0xFFF].attributes[1])
2486 {
2487 case 1:
2488 {
2489 enemy *e = new eTrap2(x,y,new_id,clk);
2490 guys.add(e);
2491 e->x = x;
2492 e->y = y;
2493 }
2494 break;
2495
2496 case 0:
2497 default:
2498 {
2499 enemy *e = new eTrap(x,y,new_id,clk);
2500 guys.add(e);
2501 e->x = x;
2502 e->y = y;
2503 }
2504 break;
2505 }
2506
2507 break;
2508 }
2509
2510 case eeDONGO:
2511 {
2512 switch(guysbuf[new_id&0xFFF].attributes[9])
2513 {
2514 case 1:
2515 {
2516 enemy *e = new eDodongo2(x,y,new_id,clk);
2517 guys.add(e);
2518 e->x = x;
2519 e->y = y;
2520 }
2521 break;
2522
2523 case 0:
2524 default:
2525 {
2526 enemy *e = new eDodongo(x,y,new_id,clk);
2527 guys.add(e);
2528 e->x = x;
2529 e->y = y;
2530 }
2531 break;
2532 }
2533
2534 break;
2535 }
2536
2537 case eeDIG:
2538 {
2539 switch(guysbuf[new_id&0xFFF].attributes[9])
2540 {
2541 case 1:
2542 {
2543 enemy *e = new eLilDig(x,y,new_id,clk);
2544 guys.add(e);
2545 e->x = x;
2546 e->y = y;
2547 }
2548 break;
2549
2550 case 0:
2551 default:
2552 {
2553 enemy *e = new eBigDig(x,y,new_id,clk);
2554 guys.add(e);
2555 e->x = x;
2556 e->y = y;
2557 }
2558 break;
2559 }
2560
2561 break;
2562 }
2563
2564 case eePATRA:
2565 {
2566 switch(guysbuf[new_id&0xFFF].attributes[9])
2567 {
2568 case 1:
2569 {
2570 if (get_qr(qr_HARDCODED_BS_PATRA))
2571 {
2572 enemy *e = new ePatraBS(x,y,new_id,clk);
2573 guys.add(e);
2574 e->x = x;
2575 e->y = y;
2576 break;
2577 }
2578 }
2579 [[fallthrough]];
2580 case 0:
2581 default:
2582 {
2583 enemy *e = new ePatra(x,y,new_id,clk);
2584 guys.add(e);
2585 e->x = x;
2586 e->y = y;
2587 }
2588 break;
2589 }
2590
2591 break;
2592 }
2593
2594 case eeGUY:
2595 {
2596 switch(guysbuf[new_id&0xFFF].attributes[9])
2597 {
2598 case 1:
2599 {
2600 enemy *e = new eTrigger(x,y,new_id,clk);
2601 guys.add(e);
2602 }
2603 break;
2604
2605 case 0:
2606 default:
2607 {
2608 enemy *e = new eNPC(x,y,new_id,clk);
2609 guys.add(e);
2610 }
2611 break;
2612 }
2613
2614 break;
2615 }
2616
2617 case eeSCRIPT01:
2618 case eeSCRIPT02:
2619 case eeSCRIPT03:
2620 case eeSCRIPT04:
2621 case eeSCRIPT05:
2622 case eeSCRIPT06:
2623 case eeSCRIPT07:
2624 case eeSCRIPT08:
2625 case eeSCRIPT09:
2626 case eeSCRIPT10:
2627 case eeSCRIPT11:
2628 case eeSCRIPT12:
2629 case eeSCRIPT13:
2630 case eeSCRIPT14:
2631 case eeSCRIPT15:
2632 case eeSCRIPT16:
2633 case eeSCRIPT17:
2634 case eeSCRIPT18:
2635 case eeSCRIPT19:
2636 case eeSCRIPT20:
2637 {
2638 enemy *e = new eScript(x,y,new_id,clk);
2639 guys.add(e);
2640 e->x = x;
2641 e->y = y;
2642 break;
2643 }
2644
2645
2646 case eeFFRIENDLY01:
2647 case eeFFRIENDLY02:
2648 case eeFFRIENDLY03:
2649 case eeFFRIENDLY04:
2650 case eeFFRIENDLY05:
2651 case eeFFRIENDLY06:
2652 case eeFFRIENDLY07:
2653 case eeFFRIENDLY08:
2654 case eeFFRIENDLY09:
2655 case eeFFRIENDLY10:
2656 {
2657 enemy *e = new eFriendly(x,y,new_id,clk);
2658 guys.add(e);
2659 e->x = x;
2660 e->y = y;
2661 break;
2662 }
2663
2664
2665 default: break;
2666 }
2667
2668 // add segments of segmented enemies
2669 int32_t c=0;
2670
2671 switch(guysbuf[new_id&0xFFF].type)
2672 {
2673 case eeMOLD:
2674 {
2675 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2676 new_id &= 0xFFF;
2677
2678 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].attributes[0])); i++)
2679 {
2680 //christ this is messy -DD
2681 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
2682
2683 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
2684 {
2685 al_trace("Moldorm segment %d could not be created!\n",i+1);
2686
2687 for(int32_t j=0; j<i+1; j++)
2688 guys.del(guys.Count()-1);
2689
2690 return 0;
2691 }
2692
2693 if(i>0)
2694 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2695
2696
2697 }
2698
2699 break;
2700 }
2701
2702 case eeLANM:
2703 {
2704 new_id &= 0xFFF;
2705 int32_t shft = guysbuf[new_id].attributes[1];
2706 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2707 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
2708
2709 if(!guys.add(e))
2710 {
2711 al_trace("Lanmola segment 1 could not be created!\n");
2712 guys.del(guys.Count()-1);
2713 return 0;
2714 }
2715 e->x = x;
2716 e->y = y;
2717
2718
2719
2720 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])); i++)
2721 {
2722 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
2723 if(!guys.add(e2))
2724 {
2725 al_trace("Lanmola segment %d could not be created!\n",i+1);
2726
2727 for(int32_t j=0; j<i+1; j++)
2728 guys.del(guys.Count()-1);
2729
2730 return 0;
2731 }
2732 e2->x = x;
2733 e2->y = y;
2734
2735 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2736
2737 }
2738 }
2739 break;
2740
2741 case eeMANHAN:
2742 new_id &= 0xFFF;
2743
2744 for(int32_t i=0; i<((!(guysbuf[new_id].attributes[1]))?4:8); i++)
2745 {
2746 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
2747 {
2748 al_trace("Manhandla head %d could not be created!\n",i+1);
2749
2750 for(int32_t j=0; j<i+1; j++)
2751 {
2752 guys.del(guys.Count()-1);
2753 }
2754
2755 return 0;
2756 }
2757
2758
2759 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].attributes[0];
2760 }
2761
2762 break;
2763
2764 case eeGLEEOK:
2765 {
2766 /*
2767 new_id &= 0xFFF;
2768 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2769 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2770 for(int32_t i=0; i<head_cnt; i++)
2771 {
2772 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2773 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2774 {
2775 al_trace("Gleeok head %d could not be created!\n",i+1);
2776
2777 for(int32_t j=0; j<i+1; j++)
2778 {
2779 guys.del(guys.Count()-1);
2780 }
2781
2782 break;
2783 }
2784
2785 c-=guysbuf[new_id].misc4;
2786 */
2787
2788 // }
2789 }
2790 break;
2791
2792
2793 case eePATRA:
2794 {
2795 new_id &= 0xFFF;
2796 int32_t outeyes = 0;
2797 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
2798
2799 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[0]); i++)
2800 {
2801 if(!((guysbuf[new_id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
2802 {
2803 al_trace("Patra outer eye %d could not be created!\n",i+1);
2804
2805 for(int32_t j=0; j<i+1; j++)
2806 guys.del(guys.Count()-1);
2807
2808 return 0;
2809 }
2810 else
2811 outeyes++;
2812
2813
2814 }
2815
2816 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[1]); i++)
2817 {
2818 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
2819 {
2820 al_trace("Patra inner eye %d could not be created!\n",i+1);
2821
2822 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
2823 guys.del(guys.Count()-1);
2824
2825 return 0;
2826 }
2827
2828
2829 }
2830 delete ptra;
2831 break;
2832 }
2833 }
2834
2835
2836 // TODO(crash): check that the above .add succeeded.
2837 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
2838 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2839 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
2840 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
2841 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
2842 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
2843 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
2844 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
2845 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
2846 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2847 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
2848 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
2849
2850
2851 item_set = 0; //Do not make a drop.
2852
2853 switch(effect_type)
2854 {
2855 case -7:
2856 {
2857 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
2858 Lwpns.add(w);
2859 break;
2860 }
2861 case -6:
2862 {
2863 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
2864 Lwpns.add(w);
2865 break;
2866 }
2867 case -5:
2868 {
2869 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2870 Lwpns.add(w);
2871 break;
2872 }
2873 case -4:
2874 {
2875 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2876 Lwpns.add(w);
2877 break;
2878 }
2879 case -3: explode(1); break;
2880 case -2: explode(2); break;
2881 case -1: explode(0); break;
2882 case 0: break;
2883
2884 default:
2885 {
2886 //Dummy weapon function
2887 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
2888 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
2889 Lwpns.add(w);
2890 break;
2891 }
2892 }
2893
2894
2895 yofs = -32768;
2896 switch(guysbuf[new_id&0xFFF].type)
2897 {
2898 case eeGLEEOK:
2899 {
2900 Z_scripterrlog("Replacing a gleeok.\n");
2901 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
2902 hp = -999;
2903 if (tempenemy) tempenemy->hp = -999;
2904 break;
2905
2906 }
2907 default:
2908 hp = -1000; break;
2909 }
2910 int mi = mapind(cur_map, screen_spawned);
2911 ++game->guys[mi];
2912 return 1;
2913
2914 }
2915 case edSPLIT:
2916 {
2917 for ( int32_t q = 0; q < dmisc4; q++ )
2918 {
2919 addenemy(screen_spawned,x,y,
2920 dmisc3+0x1000,-15);
2921
2922 }
2923 item_set = 0; //Do not make a drop.
2924 hp = -1000;
2925 return -1;
2926
2927 }
2928 case edSUMMON:
2929 {
2930 int32_t summon_count = zc::math::SafeMod(zc_oldrand(), dmisc4) + 1;
2931 for ( int32_t q = 0; q < summon_count; q++ )
2932 {
2933 int32_t x2=16*((zc_oldrand()%12)+2);
2934 int32_t y2=16*((zc_oldrand()%7)+2);
2935 addenemy(screen_spawned,
2936 //(x+(txsz*16)/2),(y+(tysz*16)/2)
2937 x2,y2,
2938 dmisc3+0x1000,-15);
2939
2940 }
2941 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(x));
2942 return -1;
2943
2944 }
2945
2946 case edEXPLODESMALL:
2947 {
2948 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
2949 Ewpns.add(ew);
2950 item_set = 0; //Should we make a drop?
2951 hp = -1000;
2952 return -1;
2953 }
2954
2955
2956 case edEXPLODEHARMLESS:
2957 {
2958 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2959 Ewpns.add(ew);
2960 ew->hyofs = -32768;
2961 item_set = 0; //Should we make a drop?
2962 hp = -1000;
2963 return -1;
2964 }
2965
2966
2967 case edEXPLODELARGE:
2968 {
2969 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2970 Ewpns.add(ew);
2971
2972 hp = -1000;
2973 return -1;
2974 }
2975
2976
2977 case edTRIGGERSECRETS:
2978 {
2979 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
2980 return -1;
2981 }
2982
2983 case edSTUNORCHINK:
2984
2/2
✓ Branch 0 taken 649 times.
✓ Branch 1 taken 1526 times.
2175 if(*power <= 0)
2985 {
2986 649 sfx(WAV_CHINK,pan(x));
2987 649 return 1;
2988 }
2989
2/2
✓ Branch 0 taken 407 times.
✓ Branch 1 taken 1119 times.
2645 if (stunclk)
2990 {
2991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if(get_qr(qr_NO_STUNLOCK_IGNORE))
2992 return 0;
2993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if(get_qr(qr_NO_STUNLOCK_BLOCK))
2994 {
2995 sfx(WAV_CHINK,pan(x));
2996 return 1;
2997 }
2998 1119 }
2999 [[fallthrough]];
3000
3001 case edSTUNORIGNORE:
3002
2/2
✓ Branch 0 taken 955 times.
✓ Branch 1 taken 2502 times.
3457 if(*power <= 0)
3003 955 return 0;
3004
2/2
✓ Branch 0 taken 550 times.
✓ Branch 1 taken 1952 times.
4454 if (stunclk)
3005 {
3006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1952 times.
1952 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3007 return 0;
3008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1952 times.
1952 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3009 {
3010 sfx(WAV_CHINK,pan(x));
3011 return 1;
3012 }
3013 1952 }
3014 [[fallthrough]];
3015
3016 case edSTUNONLY:
3017
7/10
✓ Branch 0 taken 4364 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4364 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4364 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3817 times.
✓ Branch 7 taken 547 times.
✓ Branch 8 taken 4043 times.
✓ Branch 9 taken 321 times.
4364 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3018 {
3019 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3020 321 return 1;
3021 }
3022
2/2
✓ Branch 0 taken 925 times.
✓ Branch 1 taken 3118 times.
4043 if (stunclk)
3023 {
3024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3118 times.
3118 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3025 return 0;
3026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3118 times.
3118 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3027 {
3028 sfx(WAV_CHINK,pan(x));
3029 return 1;
3030 }
3031 3118 }
3032 4043 stunclk=160;
3033 4043 sfx(WAV_EHIT,pan(x));
3034 4043 return 1;
3035
3036 case edCHINKL1:
3037 if(*power >= 1*game->get_hero_dmgmult()) break;
3038 [[fallthrough]];
3039 case edCHINKL2:
3040
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 61 times.
113 if(*power >= 2*game->get_hero_dmgmult()) break;
3041 [[fallthrough]];
3042 case edCHINKL4:
3043
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 110 times.
190 if(*power >= 4*game->get_hero_dmgmult()) break;
3044 [[fallthrough]];
3045 case edCHINKL6:
3046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 6*game->get_hero_dmgmult()) break;
3047 [[fallthrough]];
3048 case edCHINKL8:
3049
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 111 times.
154 if(*power >= 8*game->get_hero_dmgmult()) break;
3050 [[fallthrough]];
3051 case edCHINKL10:
3052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 10*game->get_hero_dmgmult()) break;
3053 [[fallthrough]];
3054 case edCHINK:
3055 1056 sfx(WAV_CHINK,pan(x));
3056 1056 return 1;
3057
3058 case edIGNOREL1:
3059 if(*power > 0) break;
3060 [[fallthrough]];
3061
3062 case edIGNORE:
3063 17349 return 0;
3064
3065 case ed1HKO:
3066 492 *power = hp;
3067 492 return -3;
3068
3069 case ed2x:
3070 {
3071
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 *power = zc_max(1,*power*2);
3072 //int32_t pow = *power;
3073 //*power = vbound((pow*2),0,214747);
3074 71 return -1;
3075 }
3076 case ed3x:
3077 {
3078 *power = zc_max(1,*power*3);
3079 //int32_t pow = *power;
3080 //*power = vbound((pow*3),0,214747);
3081 return -1;
3082 }
3083
3084 case ed4x:
3085 {
3086 *power = zc_max(1,*power*4);
3087 //int32_t pow = *power;
3088 //*power = vbound((pow*4),0,214747);
3089 return -1;
3090 }
3091
3092
3093 case edHEAL:
3094 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3095 //int32_t pow = *power;
3096 //*power = vbound((pow*-1),0,214747);
3097 //break;
3098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158 times.
158 *power = zc_min(0,*power*-1);
3099 158 return -1;
3100 }
3101 /*
3102 case edLEVELDAMAGE:
3103 {
3104 int32_t pow = *power;
3105 int32_t lvl = *level;
3106 *power = vbound((pow*lvl),0,214747);
3107 break;
3108 }
3109 case edLEVELREDUCTION:
3110 {
3111 int32_t pow = *power;
3112 int32_t lvl = *level;
3113 *power = vbound((pow/lvl),0,214747);
3114 break;
3115 }
3116 */
3117
3118 case edQUARTDAMAGE:
3119
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 3 times.
105 *power = zc_max(1,*power/2);
3120
3121 [[fallthrough]];
3122 case edHALFDAMAGE:
3123
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 156 times.
988 *power = zc_max(1,*power/2);
3124 988 break;
3125
3126 case edSWITCH:
3127 {
3128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(Hero.switchhookclk) return 0; //Already switching!
3129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 switch(type)
3130 {
3131 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
3132 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
3133 return 0;
3134 }
3135 4 hooked_comborpos = rpos_t::None;
3136 4 hooked_layerbits = 0;
3137 4 switching_object = this;
3138 4 switch_hooked = true;
3139 4 Hero.doSwitchHook(game->get_switchhookstyle());
3140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(QMisc.miscsfx[sfxSWITCHED])
3141 sfx(QMisc.miscsfx[sfxSWITCHED],pan(x));
3142 4 return 1;
3143 }
3144
3145 case 0:
3146 {
3147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93608 times.
93608 if(edef == edefSwitchHook)
3148 return -1;
3149
4/4
✓ Branch 0 taken 19532 times.
✓ Branch 1 taken 74076 times.
✓ Branch 2 taken 7756 times.
✓ Branch 3 taken 11776 times.
93608 if (stunclk && *power == 0)
3150 {
3151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11776 times.
11776 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3152 return 0;
3153
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 11750 times.
11776 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3154 {
3155 26 sfx(WAV_CHINK,pan(x));
3156 26 return 1;
3157 }
3158 11750 }
3159 93582 break;
3160 }
3161 }
3162
3163 94745 return -1;
3164 126492 }
3165
3166 126492 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
3167 {
3168
1/2
✓ Branch 0 taken 126492 times.
✗ Branch 1 not taken.
126492 int wuid = w?w->getUID():0;
3169
1/2
✓ Branch 0 taken 126492 times.
✗ Branch 1 not taken.
126492 bool fakeweap = (w && !Lwpns.getByUID(wuid));
3170
3171
1/2
✓ Branch 0 taken 126492 times.
✗ Branch 1 not taken.
126492 if(fakeweap)
3172 Lwpns.add(w);
3173 126492 std::vector<int32_t> &ev = FFCore.eventData;
3174 126492 ev.clear();
3175 126492 ev.push_back(*power*10000);
3176 126492 ev.push_back(edef*10000);
3177 126492 ev.push_back(unblockable*10000);
3178 126492 ev.push_back(wpnId*10000);
3179 126492 ev.push_back(0);
3180 126492 ev.push_back(getUID());
3181 126492 ev.push_back(wuid);
3182
3183 126492 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
3184 126492 *power = ev[0]/10000;
3185 126492 edef = ev[1]/10000;
3186 126492 unblockable = byte(ev[2]/10000);
3187 126492 wpnId = ev[3] / 10000;
3188 126492 bool nullify = ev[4]!=0;
3189 126492 ev.clear();
3190 126492 int ret = 0;
3191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126492 times.
126492 if(!nullify)
3192 {
3193 126492 ret = defendNew(wpnId, power, edef, unblockable);
3194
2/2
✓ Branch 0 taken 32388 times.
✓ Branch 1 taken 94104 times.
126492 if(ret < 0)
3195 {
3196 94104 ev.push_back(*power*10000);
3197 94104 ev.push_back(edef*10000);
3198 94104 ev.push_back(unblockable*10000);
3199 94104 ev.push_back(wpnId*10000);
3200 94104 ev.push_back(0);
3201 94104 ev.push_back(getUID());
3202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94104 times.
94104 ev.push_back(w?w->getUID():0);
3203
3204 94104 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
3205 94104 *power = ev[0]/10000;
3206 94104 nullify = ev[4]!=0;
3207 94104 ev.clear();
3208 94104 }
3209 126492 }
3210
1/2
✓ Branch 0 taken 126492 times.
✗ Branch 1 not taken.
126492 if(fakeweap)
3211 Lwpns.remove(w);
3212
3213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126492 times.
126492 return nullify ? 0 : ret;
3214 }
3215
3216 99683 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
3217 {
3218
2/2
✓ Branch 0 taken 99106 times.
✓ Branch 1 taken 577 times.
99683 if(!realweap) realweap = w;
3219 99683 int32_t wid = getWeaponID(w);
3220
3221 99683 int32_t edef = resolveEnemyDefence(w);
3222
2/2
✓ Branch 0 taken 6268 times.
✓ Branch 1 taken 93415 times.
99683 if(QHeader.zelda_version > 0x250)
3223 6268 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3224
2/3
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 92422 times.
✗ Branch 2 not taken.
93415 switch(wid)
3225 {
3226 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
3227 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
3228 993 return defend(wpnId, power, edefSCRIPT);
3229
3230 case wWhistle:
3231 return -1;
3232
3233 default:
3234 92422 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3235 }
3236 99683 }
3237
3238
3239 // Check defenses without actually acting on them.
3240 27402 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
3241 {
3242
4/10
✓ Branch 0 taken 15409 times.
✓ Branch 1 taken 11050 times.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
27402 switch(defense[edef])
3243 {
3244 case edSTUNONLY:
3245 474 return false;
3246 case edSTUNORCHINK:
3247 case edCHINK:
3248 15409 return unblockable&WPNUNB_BLOCK;
3249 case edSTUNORIGNORE:
3250 case edIGNORE:
3251 11050 return unblockable&WPNUNB_IGNR;
3252
3253 case edIGNOREL1:
3254 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
3255 case edCHINKL1:
3256 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
3257
3258 case edCHINKL2:
3259 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
3260
3261 case edCHINKL4:
3262 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
3263
3264 case edCHINKL6:
3265 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
3266
3267 case edCHINKL8:
3268 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
3269 }
3270
3271 469 return true;
3272 27402 }
3273
3274 // Do we do damage?
3275 // 0: takehit returns 0
3276 // 1: takehit returns 1
3277 // -1: do damage
3278 993 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
3279 {
3280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993 times.
993 if(shieldCanBlock)
3281 {
3282 switch(defense[edef])
3283 {
3284 case edIGNORE:
3285 return 0;
3286 case edIGNOREL1:
3287 case edSTUNORIGNORE:
3288 if(*power <= 0)
3289 return 0;
3290 }
3291
3292 sfx(WAV_CHINK,pan(x));
3293 return 1;
3294 }
3295
3296
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
993 switch(defense[edef])
3297 {
3298 case edSTUNORCHINK:
3299 if(*power <= 0)
3300 {
3301 sfx(WAV_CHINK,pan(x));
3302 return 1;
3303 }
3304
3305 [[fallthrough]];
3306 case edSTUNORIGNORE:
3307 if(*power <= 0)
3308 return 0;
3309
3310 [[fallthrough]];
3311 case edSTUNONLY:
3312 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3313 return 1;
3314
3315 stunclk=160;
3316 sfx(WAV_EHIT,pan(x));
3317 return 1;
3318
3319 case edFREEZE:
3320 frozenclock=-1;
3321 //sfx(WAV_FREEZE,pan(x));
3322 return 1;
3323
3324 case edCHINKL1:
3325 if(*power >= 1*game->get_hero_dmgmult()) break;
3326 [[fallthrough]];
3327 case edCHINKL2:
3328 if(*power >= 2*game->get_hero_dmgmult()) break;
3329 [[fallthrough]];
3330 case edCHINKL4:
3331 if(*power >= 4*game->get_hero_dmgmult()) break;
3332 [[fallthrough]];
3333 case edCHINKL6:
3334 if(*power >= 6*game->get_hero_dmgmult()) break;
3335 [[fallthrough]];
3336 case edCHINKL8:
3337 if(*power >= 8*game->get_hero_dmgmult()) break;
3338 [[fallthrough]];
3339 case edCHINKL10:
3340 if(*power >= 10*game->get_hero_dmgmult()) break;
3341 [[fallthrough]];
3342 case edCHINK:
3343 sfx(WAV_CHINK,pan(x));
3344 return 1;
3345 case edTRIGGERSECRETS:
3346 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
3347 break;
3348
3349 case edIGNOREL1:
3350 if(*power > 0) break;
3351 [[fallthrough]];
3352 case edIGNORE:
3353 800 return 0;
3354
3355 case ed1HKO:
3356 *power = hp;
3357 return -3;
3358
3359 case ed2x:
3360 {
3361 *power = zc_max(1,*power*2);
3362 //int32_t pow = *power;
3363 //*power = vbound((pow*2),0,214747);
3364 return -1;
3365 }
3366 case ed3x:
3367 {
3368 *power = zc_max(1,*power*3);
3369 //int32_t pow = *power;
3370 //*power = vbound((pow*3),0,214747);
3371 return -1;
3372 }
3373
3374 case ed4x:
3375 {
3376 *power = zc_max(1,*power*4);
3377 //int32_t pow = *power;
3378 //*power = vbound((pow*4),0,214747);
3379 return -1;
3380 }
3381
3382
3383 case edHEAL:
3384 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3385 //int32_t pow = *power;
3386 //*power = vbound((pow*-1),0,214747);
3387 //break;
3388 *power = zc_min(0,*power*-1);
3389 return -1;
3390 }
3391 /*
3392 case edLEVELDAMAGE:
3393 {
3394 int32_t pow = *power;
3395 int32_t lvl = *level;
3396 *power = vbound((pow*lvl),0,214747);
3397 break;
3398 }
3399 case edLEVELREDUCTION:
3400 {
3401 int32_t pow = *power;
3402 int32_t lvl = *level;
3403 *power = vbound((pow/lvl),0,214747);
3404 break;
3405 }
3406 */
3407
3408
3409 case edQUARTDAMAGE:
3410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3411
3412 [[fallthrough]];
3413 case edHALFDAMAGE:
3414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3415 7 break;
3416 }
3417
3418 193 return -1;
3419 993 }
3420
3421 // Defend against a particular item class.
3422 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
3423 {
3424 int32_t def=-1;
3425
3426 switch(wpnId)
3427 {
3428 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
3429 case wBrang:
3430 def = defend(wpnId, power, edefBRANG);
3431 break;
3432
3433 case wHookshot:
3434 def = defend(wpnId, power, edefHOOKSHOT);
3435 break;
3436
3437 // Anyway...
3438 case wBomb:
3439 def = defend(wpnId, power, edefBOMB);
3440 break;
3441
3442 case wSBomb:
3443 def = defend(wpnId, power, edefSBOMB);
3444 break;
3445
3446 case wArrow:
3447 def = defend(wpnId, power, edefARROW);
3448 break;
3449
3450 case wFire:
3451 def = defend(wpnId, power, edefFIRE);
3452 break;
3453
3454 case wWand:
3455 def = defend(wpnId, power, edefWAND);
3456 break;
3457
3458 case wMagic:
3459 def = defend(wpnId, power, edefMAGIC);
3460 break;
3461
3462 case wHammer:
3463 def = defend(wpnId, power, edefHAMMER);
3464 break;
3465
3466 case wSword:
3467 def = defend(wpnId, power, edefSWORD);
3468 break;
3469
3470 case wBeam:
3471 def = defend(wpnId, power, edefBEAM);
3472 break;
3473
3474 case wRefBeam:
3475 def = defend(wpnId, power, edefREFBEAM);
3476 break;
3477
3478 case wRefMagic:
3479 def = defend(wpnId, power, edefREFMAGIC);
3480 break;
3481
3482 case wRefFireball:
3483 def = defend(wpnId, power, edefREFBALL);
3484 break;
3485
3486 case wRefRock:
3487 def = defend(wpnId, power, edefREFROCK);
3488 break;
3489
3490 case wStomp:
3491 def = defend(wpnId, power, edefSTOMP);
3492 break;
3493
3494 case wCByrna:
3495 def = defend(wpnId, power, edefBYRNA);
3496 break;
3497
3498 case wScript1:
3499 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
3500 else def = defend(wpnId, power, edefSCRIPT);
3501 break;
3502
3503 case wScript2:
3504 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
3505 else def = defend(wpnId, power, edefSCRIPT);
3506 break;
3507
3508 case wScript3:
3509 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
3510 else def = defend(wpnId, power, edefSCRIPT);
3511 break;
3512
3513 case wScript4:
3514 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
3515 else def = defend(wpnId, power, edefSCRIPT);
3516 break;
3517
3518 case wScript5:
3519 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
3520 else def = defend(wpnId, power, edefSCRIPT);
3521 break;
3522
3523 case wScript6:
3524 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
3525 else def = defend(wpnId, power, edefSCRIPT);
3526 break;
3527
3528 case wScript7:
3529 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
3530 else def = defend(wpnId, power, edefSCRIPT);
3531 break;
3532
3533 case wScript8:
3534 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
3535 else def = defend(wpnId, power, edefSCRIPT);
3536 break;
3537
3538 case wScript9:
3539 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
3540 else def = defend(wpnId, power, edefSCRIPT);
3541 break;
3542
3543 case wScript10:
3544 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
3545 else def = defend(wpnId, power, edefSCRIPT);
3546 break;
3547
3548 case wWhistle:
3549 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
3550 else break;
3551 break;
3552
3553 case wRefArrow:
3554 def = defend(wpnId, power, edefREFARROW);
3555 break;
3556 case wRefFire:
3557 def = defend(wpnId, power, edefREFFIRE);
3558 break;
3559 case wRefFire2:
3560 def = defend(wpnId, power, edefREFFIRE2);
3561 break;
3562
3563 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
3564 //Probably best to do this from the qest file, loading the values of Script(generic) into each
3565 //of the ten if the quest version is lower than N.
3566 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
3567 //such as bool UseSeparatedScriptDefences. hah.
3568 default:
3569 //if(wpnId>=wScript1 && wpnId<=wScript10)
3570 // {
3571 // def = defend(wpnId, power, edefSCRIPT);
3572 // }
3573 // }
3574
3575 break;
3576 }
3577
3578 return def;
3579 }
3580
3581 // take damage or ignore it
3582 // 2 or -2: force wait a frame
3583 // < 0: damage (if any) dealt
3584 // > 0: blocked
3585 // 0: weapon passes through unhindered
3586 265281 int32_t enemy::takehit(weapon *w, weapon* realweap)
3587 {
3588
2/4
✓ Branch 0 taken 265281 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 265281 times.
265281 if(fallclk||drownclk) return 0;
3589
2/2
✓ Branch 0 taken 69774 times.
✓ Branch 1 taken 195507 times.
265281 if(!realweap) realweap = w;
3590 265281 int32_t wpnId = w->id;
3591 265281 int32_t power = w->power;
3592 265281 int32_t wpnx = w->x;
3593 265281 int32_t wpny = w->y;
3594 265281 int32_t enemyHitWeapon = w->parentitem;
3595 int32_t wpnDir;
3596 265281 int32_t parent_item = w->parentitem;
3597
3598
2/2
✓ Branch 0 taken 265166 times.
✓ Branch 1 taken 115 times.
265281 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
3599 {
3600 115 wpnId = w->useweapon;
3601 115 }
3602
3603 // If it's a boomerang that just bounced, use the opposite direction;
3604 // otherwise, it might bypass a shield. This probably won't handle
3605 // every case correctly, but it's better than having shields simply
3606 // not work against boomerangs.
3607
8/8
✓ Branch 0 taken 25081 times.
✓ Branch 1 taken 240200 times.
✓ Branch 2 taken 15580 times.
✓ Branch 3 taken 9501 times.
✓ Branch 4 taken 14362 times.
✓ Branch 5 taken 1218 times.
✓ Branch 6 taken 3306 times.
✓ Branch 7 taken 11056 times.
265281 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
3608 11056 wpnDir = oppositeDir[w->dir];
3609 else
3610 254225 wpnDir = w->dir;
3611
3612
5/8
✓ Branch 0 taken 265281 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 265281 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 265281 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8040 times.
✓ Branch 7 taken 272607 times.
265281 if(dying || clk<0 || hclk>0 || superman)
3613 8040 return 0;
3614
3615 //Prevent boomerang from writing to hitby[] for more than one frame.
3616 //This also prevents stunlock.
3617 //if ( stunclk > 0 ) return 0;
3618 //this needs a rule for boomerangs that cannot stunlock!
3619 //further, bouncing weapons should probably SFX_CHINK and bounce here.
3620 //sigh.
3621
3622 272607 int32_t ret = -1;
3623
3624 // This obscure quest rule...
3625
5/6
✓ Branch 0 taken 92333 times.
✓ Branch 1 taken 180274 times.
✓ Branch 2 taken 88830 times.
✓ Branch 3 taken 3503 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 88830 times.
272607 if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
3626 {
3627 double _MSVC2022_tmp1, _MSVC2022_tmp2;
3628 3503 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
3629 3503 wpnDir=zc_oldrand()&3;
3630
3631
4/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 3036 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 189 times.
3503 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
3632 {
3633 189 wpnDir=down;
3634 189 }
3635
4/4
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 2751 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 285 times.
3314 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
3636 {
3637 285 wpnDir=right;
3638 285 }
3639
4/4
✓ Branch 0 taken 2342 times.
✓ Branch 1 taken 687 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 2064 times.
3029 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
3640 {
3641 2064 wpnDir=up;
3642 2064 }
3643 else
3644 {
3645 965 wpnDir=left;
3646 }
3647 3503 }
3648
3649 272607 int32_t xdir = dir;
3650 272607 shieldCanBlock=false;
3651
3652
4/4
✓ Branch 0 taken 261327 times.
✓ Branch 1 taken 11280 times.
✓ Branch 2 taken 2767 times.
✓ Branch 3 taken 258560 times.
273369 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
3653
6/6
✓ Branch 0 taken 18380 times.
✓ Branch 1 taken 15613 times.
✓ Branch 2 taken 26253 times.
✓ Branch 3 taken 247920 times.
✓ Branch 4 taken 108 times.
✓ Branch 5 taken 247812 times.
261327 || ((flags&guy_shield_front && wpnDir==(xdir^down)) || (flags&guy_shield_back && wpnDir==(xdir^up)) ||
3654
4/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 246793 times.
✓ Branch 2 taken 762 times.
✓ Branch 3 taken 246031 times.
247812 (flags&guy_shield_left && wpnDir==(xdir^(xdir&2?right:left))) || (flags&guy_shield_right && wpnDir==(xdir^(dir&2?left:right)))))
3655 )
3656 // The hammer should already be dealt with by subclasses (Walker etc.)
3657 {
3658
10/10
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 380 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 680 times.
✓ Branch 4 taken 5804 times.
✓ Branch 5 taken 338 times.
✓ Branch 6 taken 14 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 153 times.
✓ Branch 9 taken 1488 times.
46522 switch(wpnId)
3659 {
3660 // Weapons which shields protect against
3661 case wSword:
3662 case wWand:
3663
2/2
✓ Branch 0 taken 5802 times.
✓ Branch 1 taken 2 times.
5806 if(Hero.getCharging()>0)
3664 2 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
3665
3666 [[fallthrough]];
3667 case wHookshot:
3668 case wHSHandle:
3669 case wBrang:
3670 6184 shieldCanBlock=true;
3671 6522 break;
3672
3673 case wBeam:
3674 case wRefBeam:
3675 // Mirror shielded enemies!
3676 #if 0
3677 if(false /*flags&guy_mirror*/ && !get_qr(qr_SWORDMIRROR))
3678 {
3679 if(wpnId>wEnemyWeapons)
3680 return 0;
3681
3682 sfx(WAV_CHINK,pan(x));
3683 return 1;
3684 }
3685
3686 #endif
3687
3688 [[fallthrough]];
3689 case wRefRock:
3690 case wRefFireball:
3691 case wMagic:
3692 #if 0
3693 if(false /*flags&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS)))
3694 {
3695 sfx(WAV_CHINK,pan(x));
3696 return 3;
3697 }
3698
3699 #endif
3700
3701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 368 times.
368 if(wpnId>wEnemyWeapons)
3702 return 0;
3703
3704 [[fallthrough]];
3705 case wArrow:
3706 382 case wRefArrow:
3707 default:
3708 1870 shieldCanBlock=true;
3709 1870 break;
3710
3711 // Bombs
3712 case wSBomb:
3713 case wBomb:
3714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
3715 else if (!get_qr(qr_BOMBSPIERCESHIELD))
3716 {
3717 sfx(WAV_CHINK,pan(x));
3718 return 0;
3719 }
3720 else break;
3721
3722 // Weapons which ignore shields
3723 case wWhistle:
3724 case wHammer:
3725 153 break;
3726
3727 // Weapons which shouldn't be removed by shields
3728 case wLitBomb:
3729 case wLitSBomb:
3730 case wWind:
3731 case wPhantom:
3732 case wSSparkle:
3733 case wBait:
3734 864 return 0;
3735
3736 case wFire:
3737 case wRefFire:
3738 case wRefFire2:
3739 ;
3740 680 }
3741 8887 }
3742
3743
8/8
✓ Branch 0 taken 103219 times.
✓ Branch 1 taken 98026 times.
✓ Branch 2 taken 423 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 27402 times.
✓ Branch 5 taken 25035 times.
✓ Branch 6 taken 2767 times.
✓ Branch 7 taken 9056 times.
266198 switch(wpnId)
3744 {
3745 case wWhistle: //No longer completely ignore whistle weapons! -Z
3746 {
3747
3748
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
423 if ( ((itemsbuf[parent_item].flags & item_flag2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
3749 {
3750 423 return 0; break;
3751 }
3752 else
3753 {
3754 w->power = power = itemsbuf[parent_item].misc5;
3755
3756 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3757
3758 if(def <= 0)
3759 {
3760 hp -= power;
3761 return def;
3762 }
3763 break;
3764 }
3765 break;
3766 }
3767
3768 case wPhantom:
3769 270 return 0;
3770
3771 case wLitBomb:
3772 case wLitSBomb:
3773 case wBait:
3774 case wWind:
3775 case wSSparkle:
3776 103219 return 0;
3777
3778 case wFSparkle:
3779
3780 // Only take sparkle damage if the sparkle's parent item is not
3781 // defended against.
3782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27402 times.
27402 if(enemyHitWeapon > -1)
3783 {
3784 27402 int32_t p = 0;
3785 27402 int32_t f = itemsbuf[enemyHitWeapon].type;
3786
3787
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27402 times.
27402 switch(f)
3788 {
3789 case itype_arrow:
3790 if(!candamage(p, edefARROW, w->unblockable)) return 0;
3791
3792 break;
3793
3794 case itype_cbyrna:
3795 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
3796
3797 break;
3798
3799 case itype_brang:
3800
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 26933 times.
27402 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
3801
3802 469 break;
3803
3804 default:
3805 return 0;
3806 }
3807 469 }
3808
3809 469 wpnId = wSword;
3810 469 power = game->get_hero_dmgmult()>>1;
3811 469 goto fsparkle;
3812 break;
3813
3814 case wBrang:
3815 {
3816 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
3817 25035 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3818 //preventing stunlock might be best, here. -Z
3819
2/2
✓ Branch 0 taken 5471 times.
✓ Branch 1 taken 19564 times.
25035 if(def >= 0) return def;
3820 19564 ret = def;
3821
3822 // Not hurt by 0-damage weapons
3823
2/2
✓ Branch 0 taken 3184 times.
✓ Branch 1 taken 16380 times.
19564 if(!(flags & guy_bhit))
3824 {
3825 16380 stunclk=160;
3826
3827
3/4
✓ Branch 0 taken 16380 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1311 times.
✓ Branch 3 taken 15069 times.
16380 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
3828 {
3829
1/2
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
1311 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
3830 1311 goto hitclock;
3831 }
3832
3833 15069 break;
3834 }
3835
3836
2/2
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 2793 times.
3184 if(!power)
3837
1/2
✓ Branch 0 taken 2793 times.
✗ Branch 1 not taken.
2793 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].level : current_item(itype_brang))*game->get_hero_dmgmult();
3838 else
3839 391 hp-=power;
3840
3841 3184 goto hitclock;
3842 }
3843
3844 case wHookshot:
3845 {
3846 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
3847 2767 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3848
3849
2/2
✓ Branch 0 taken 994 times.
✓ Branch 1 taken 1773 times.
2767 if(def >= 0) return def;
3850 1773 ret = def;
3851
3852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1773 times.
1773 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
3853
3/4
✓ Branch 0 taken 1773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625 times.
✓ Branch 3 taken 148 times.
1773 if(swgrab || !(flags & guy_bhit))
3854 {
3855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1625 times.
1625 if(!swgrab)
3856 1625 stunclk=160;
3857
3858
3/4
✓ Branch 0 taken 1625 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549 times.
✓ Branch 3 taken 1076 times.
1625 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
3859 {
3860
1/2
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
549 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
3861 549 goto hitclock;
3862 }
3863
3864 1076 break;
3865 }
3866
3867
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 103 times.
✗ Branch 3 not taken.
148 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].level : current_item(itype_hookshot))*game->get_hero_dmgmult();
3868 else
3869 45 hp-=power;
3870
3871 148 goto hitclock;
3872 }
3873 break;
3874
3875 case wHSHandle:
3876 {
3877
3/4
✓ Branch 0 taken 9056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✓ Branch 3 taken 8533 times.
9056 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & item_flag1)
3878 523 return 0;
3879
3880
3/4
✓ Branch 0 taken 6093 times.
✓ Branch 1 taken 2440 times.
✓ Branch 2 taken 2440 times.
✗ Branch 3 not taken.
8533 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
3881
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2440 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
3882
3883 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
3884
6/8
✓ Branch 0 taken 2787 times.
✓ Branch 1 taken 5746 times.
✓ Branch 2 taken 2787 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2787 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 502 times.
✓ Branch 7 taken 2285 times.
10245 if(!(type==eePEAHAT || type==eeAQUA || type==eeMANHAN || (type==eeWIZZ && !ignorehookshot)
3885
6/6
✓ Branch 0 taken 3375 times.
✓ Branch 1 taken 2873 times.
✓ Branch 2 taken 1771 times.
✓ Branch 3 taken 3889 times.
✓ Branch 4 taken 1712 times.
✓ Branch 5 taken 2177 times.
2787 || (type==eeWALK && dmisc9==e9tPOLSVOICE) || (type==eeWALK && flags&(guy_shield_back|guy_shield_front|guy_shield_left|guy_shield_right))))
3886 2177 return 0;
3887
3888 12102 power = game->get_hero_dmgmult();
3889 12571 }
3890
3891 fsparkle:
3892
3893 [[fallthrough]];
3894 default:
3895 // Work out the defenses!
3896 {
3897 99105 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
3898
3899
2/2
✓ Branch 0 taken 26566 times.
✓ Branch 1 taken 72539 times.
99105 if(def >= 0)
3900 26566 return def;
3901
2/2
✓ Branch 0 taken 72079 times.
✓ Branch 1 taken 460 times.
72539 else if(def == -3) // OHKO... doesn't 'hit' the weapon?
3902 460 ret = 0;
3903 }
3904
3905
2/2
✓ Branch 0 taken 72537 times.
✓ Branch 1 taken 2 times.
145078 if(!power)
3906 {
3907
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
3908 2 hp-=1;
3909 else
3910 {
3911 // Don't make a long chain of 'stun' hits
3912 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
3913 return 1;
3914
3915
3916 if(!switch_hooked)
3917 stunclk=160;
3918 break;
3919 }
3920 2 }
3921 72537 else hp-=power;
3922
3923 hitclock:
3924 77742 hclk=33;
3925
3926 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
3927
2/2
✓ Branch 0 taken 34732 times.
✓ Branch 1 taken 43010 times.
77742 if((dir&2)==(w->dir&2))
3928 {
3929 43010 sclk=(w->dir<<8)+16;
3930 43010 }
3931 77742 }
3932
3933
5/6
✓ Branch 0 taken 74323 times.
✓ Branch 1 taken 19564 times.
✓ Branch 2 taken 21982 times.
✓ Branch 3 taken 71905 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21982 times.
93887 if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
3934 {
3935 21982 fading=fade_blue_poof;
3936 21982 }
3937
3938
6/6
✓ Branch 0 taken 88602 times.
✓ Branch 1 taken 5285 times.
✓ Branch 2 taken 46937 times.
✓ Branch 3 taken 41665 times.
✓ Branch 4 taken 2347 times.
✓ Branch 5 taken 44590 times.
93887 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
3939 {
3940
1/2
✓ Branch 0 taken 7632 times.
✗ Branch 1 not taken.
7632 if( hitsfx > 0 ) //user-set hit sound.
3941 {
3942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7632 times.
7632 if (!dying) //don't play the hit sound on death! -Z
3943 7632 sfx(hitsfx, pan(x));
3944 7632 }
3945 else sfx(WAV_EHIT, pan(x)); //Don't play the hardcoded sound if the user sets a custom one.
3946 7632 }
3947 else //2.50.2 or earlier
3948 {
3949 86255 sfx(WAV_EHIT, pan(x));
3950 86255 sfx(hitsfx, pan(x));
3951 }
3952
2/2
✓ Branch 0 taken 93858 times.
✓ Branch 1 taken 29 times.
93887 if(type==eeGUY)
3953 29 sfx(WAV_EDEAD, pan(x));
3954
3955 // Penetrating weapons
3956
4/4
✓ Branch 0 taken 92013 times.
✓ Branch 1 taken 1874 times.
✓ Branch 2 taken 85107 times.
✓ Branch 3 taken 8780 times.
93887 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
3957 {
3958 8780 int32_t item=enemyHitWeapon;
3959
3960
2/2
✓ Branch 0 taken 1612 times.
✓ Branch 1 taken 7168 times.
8780 if(wpnId==wArrow)
3961 {
3962 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3963
5/6
✓ Branch 0 taken 1484 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 379 times.
✓ Branch 3 taken 1105 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 379 times.
1612 if(item>=0 && (itemsbuf[item].flags&item_flag1) && (itemsbuf[parent_item].type == itype_arrow))
3964 379 return 0;
3965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1233 times.
1233 else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0;
3966 //if(item<0)
3967 else
3968 1233 item=current_item_id(itype_arrow);
3969 1233 }
3970
3971 else
3972 {
3973
3974 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3975
3/6
✓ Branch 0 taken 7150 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7150 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7168 if(item>=0 && (itemsbuf[item].flags&item_flag3) && (itemsbuf[parent_item].type == itype_sword))
3976 return 0;
3977
3978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7168 times.
7168 else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
3979 else
3980 //if(item<0)
3981 7168 item=current_item_id(itype_sword);
3982 }
3983 8401 }
3984
3985 93508 return ret;
3986 269367 }
3987
3988 61890611 bool enemy::dont_draw()
3989 {
3990
6/6
✓ Branch 0 taken 61426098 times.
✓ Branch 1 taken 464513 times.
✓ Branch 2 taken 61355191 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 175008 times.
✓ Branch 5 taken 61251090 times.
61890611 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
3991 639521 return true;
3992
3993
2/2
✓ Branch 0 taken 1371825 times.
✓ Branch 1 taken 59879265 times.
61251090 if(flags&guy_invisible)
3994 1371825 return true;
3995
3996
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 59878833 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432 times.
59879265 if(flags&guy_lens_only && !lensclk)
3997 return true;
3998
3999 59879265 return false;
4000 61890611 }
4001
4002 #define DRAW_NORMAL 2
4003 #define DRAW_CLOAKED 1
4004 #define DRAW_INVIS 0
4005 // base drawing function to be used by all derived classes instead of
4006 // sprite::draw()
4007 44971115 void enemy::draw(BITMAP *dest)
4008 {
4009 44971115 didScriptThisFrame = false; //Since there's no better place to put it
4010
6/6
✓ Branch 0 taken 44205983 times.
✓ Branch 1 taken 765132 times.
✓ Branch 2 taken 44123333 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 317531 times.
✓ Branch 5 taken 43888452 times.
44971115 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4011 1082663 return;
4012
2/2
✓ Branch 0 taken 2767665 times.
✓ Branch 1 taken 41120787 times.
43888452 if(flags&guy_invisible)
4013 2767665 return;
4014
4015 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
4016 // be cloaked if they have "invisible displays as cloaked" checked.
4017
4018 41120787 byte canSee = DRAW_NORMAL;
4019 //Enemy specific stuff
4020
2/2
✓ Branch 0 taken 41119623 times.
✓ Branch 1 taken 1164 times.
41120787 if ( editorflags & ENEMY_FLAG1 )
4021 {
4022 1164 canSee = DRAW_INVIS;
4023
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
4024
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
4025 {
4026 if (game->item[dmisc13])
4027 {
4028 canSee = DRAW_NORMAL;
4029 }
4030 //else if ( lensclk && getlensid.flags SHOWINVIS )
4031 //{
4032 //
4033 //}
4034 //else
4035 //{
4036 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
4037 // //otherwisem invisible
4038 //}
4039 }
4040 1164 }
4041 //Room specific
4042 41120787 mapscr* scr = get_scr(screen_spawned);
4043
2/2
✓ Branch 0 taken 38949588 times.
✓ Branch 1 taken 2171199 times.
41120787 if (scr->flags3&fINVISROOM)
4044 {
4045
4/6
✓ Branch 0 taken 2171199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226004 times.
✓ Branch 3 taken 1945195 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 226004 times.
2397203 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
4046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226004 times.
226004 !((itemsbuf[Hero.getLastLensID()].flags & item_flag5) && lensclk) && type!=eeGANON) canSee = DRAW_CLOAKED;
4047 2171199 }
4048 //Lens check
4049
2/2
✓ Branch 0 taken 27537 times.
✓ Branch 1 taken 41093250 times.
41120787 if (lensclk)
4050 {
4051
2/2
✓ Branch 0 taken 27105 times.
✓ Branch 1 taken 432 times.
27537 if(flags&guy_lens_only)
4052 {
4053
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
4054 432 }
4055 27537 }
4056 else
4057 {
4058
2/2
✓ Branch 0 taken 41019834 times.
✓ Branch 1 taken 73416 times.
41093250 if(flags&guy_lens_only)
4059 73416 canSee = DRAW_INVIS;
4060 }
4061
3/4
✓ Branch 0 taken 74580 times.
✓ Branch 1 taken 41046207 times.
✓ Branch 2 taken 74580 times.
✗ Branch 3 not taken.
41120787 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
4062
3/4
✓ Branch 0 taken 40820203 times.
✓ Branch 1 taken 300584 times.
✓ Branch 2 taken 40820203 times.
✗ Branch 3 not taken.
41120787 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
4063
4064
2/2
✓ Branch 0 taken 41046207 times.
✓ Branch 1 taken 74580 times.
41120787 if (canSee == DRAW_INVIS)
4065 74580 return;
4066
4067
4/4
✓ Branch 0 taken 41043832 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 41043825 times.
41046207 if(fallclk||drownclk)
4068 {
4069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2382 times.
2382 if (canSee == DRAW_CLOAKED)
4070 {
4071 sprite::drawcloaked(dest);
4072 }
4073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2382 times.
2382 else if (canSee == DRAW_NORMAL)
4074 {
4075 2382 sprite::draw(dest);
4076 2382 }
4077 2382 return;
4078 }
4079 41043825 int32_t cshold=cs;
4080
4081
2/2
✓ Branch 0 taken 904261 times.
✓ Branch 1 taken 40139564 times.
41043825 if(dying)
4082 {
4083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 904261 times.
904261 if(clk2>=19)
4084 {
4085 if(!(clk2&2))
4086 {
4087 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
4088 if (canSee == DRAW_CLOAKED)
4089 {
4090 sprite::drawcloaked(dest);
4091 }
4092 else if (canSee == DRAW_NORMAL)
4093 {
4094 sprite::draw(dest);
4095 }
4096 }
4097 return;
4098 }
4099
4100 904261 flip = 0;
4101 904261 tile = wpnsbuf[spr_death].tile;
4102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 904261 times.
904261 if ( do_animation )
4103 {
4104 904261 int32_t offs = 0;
4105
2/2
✓ Branch 0 taken 853112 times.
✓ Branch 1 taken 51149 times.
904261 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4106 {
4107
2/2
✓ Branch 0 taken 49521 times.
✓ Branch 1 taken 1628 times.
51149 if(clk2 > 2)
4108 {
4109 1628 spr_death_anim_clk=0;
4110 1628 clk2=1;
4111
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1614 times.
1628 if(hp > -1000)
4112 1614 death_sfx();
4113 1628 }
4114
4/4
✓ Branch 0 taken 38450 times.
✓ Branch 1 taken 12699 times.
✓ Branch 2 taken 402 times.
✓ Branch 3 taken 38048 times.
51149 if(clk2==1 && spr_death_anim_clk>-1)
4115 {
4116 38048 ++clk2;
4117
2/2
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35666 times.
38048 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4118
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 38027 times.
38048 spr_death_anim_frm *= zc_max(1,txsz);
4119 38048 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4120
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 37972 times.
38048 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4121
6/6
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35666 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 38046 times.
✓ Branch 4 taken 36438 times.
✓ Branch 5 taken 1610 times.
38048 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4122 {
4123 1610 spr_death_anim_clk=-1;
4124 1610 clk2=1;
4125 1610 }
4126 38048 }
4127 51149 tile += spr_death_anim_frm;
4128 51149 }
4129
2/2
✓ Branch 0 taken 315607 times.
✓ Branch 1 taken 537505 times.
853112 else if(BSZ)
4130 {
4131
2/2
✓ Branch 0 taken 248172 times.
✓ Branch 1 taken 67435 times.
315607 offs = zc_min((15-clk2)/3,4);
4132 315607 }
4133
4/4
✓ Branch 0 taken 358415 times.
✓ Branch 1 taken 179090 times.
✓ Branch 2 taken 179079 times.
✓ Branch 3 taken 179336 times.
537505 else if(clk2>6 && clk2<=12)
4134 {
4135 179336 offs = 1;
4136 179336 }
4137
4138
2/2
✓ Branch 0 taken 455768 times.
✓ Branch 1 taken 448493 times.
904261 if(offs)
4139 {
4140
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 448043 times.
448493 offs *= zc_max(1,txsz);
4141 448493 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
4142
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 448055 times.
448493 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4143 448493 }
4144 904261 tile += offs;
4145 904261 }
4146
4147
6/6
✓ Branch 0 taken 853112 times.
✓ Branch 1 taken 51149 times.
✓ Branch 2 taken 537505 times.
✓ Branch 3 taken 315607 times.
✓ Branch 4 taken 189182 times.
✓ Branch 5 taken 348323 times.
904261 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4148 555938 cs = wpnsbuf[spr_death].csets&15;
4149 else
4150 348323 cs = (((clk2+5)>>1)&3)+6;
4151 904261 }
4152
3/4
✓ Branch 0 taken 1204162 times.
✓ Branch 1 taken 38935402 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1204162 times.
40139564 else if(hclk>0 && getCanFlicker())
4153 {
4154 1204162 cs = getFlashingCSet();
4155 1204162 }
4156 //draw every other frame for flickering enemies
4157
2/2
✓ Branch 0 taken 248031 times.
✓ Branch 1 taken 40795794 times.
41043825 if (is_hitflickerframe(false))
4158 {
4159
5/6
✓ Branch 0 taken 90246 times.
✓ Branch 1 taken 157785 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 90245 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 157786 times.
248031 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4160
2/4
✓ Branch 0 taken 248031 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248031 times.
248031 if (game->get_spriteflickercolor() || temp_flicker_color)
4161 {
4162 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4163 sprite_flicker_color = temp_flicker_color;
4164 sprite::draw(dest);
4165 }
4166 248031 }
4167 else
4168 {
4169
2/2
✓ Branch 0 taken 225162 times.
✓ Branch 1 taken 40570632 times.
40795794 if (canSee == DRAW_CLOAKED)
4170 {
4171 225162 sprite::drawcloaked(dest);
4172 225162 }
4173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40570632 times.
40570632 else if (canSee == DRAW_NORMAL)
4174 {
4175
1/2
✓ Branch 0 taken 40570632 times.
✗ Branch 1 not taken.
40570632 if ( frozenclock < 0 )
4176 {
4177 if ( frozentile > 0 ) tile = frozentile;
4178 loadpalset(csBOSS,frozencset);
4179 }
4180 40570632 sprite::draw(dest);
4181 40570632 }
4182 }
4183 41043825 cs=cshold;
4184 44971115 }
4185
4186 //old zc bosses
4187 40943259 void enemy::drawzcboss(BITMAP *dest)
4188 {
4189 40943259 didScriptThisFrame = false; //Since there's no better place to put it
4190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40943259 times.
40943259 if(dont_draw())
4191 return;
4192
4193 40943259 int32_t cshold=cs;
4194
4195
2/2
✓ Branch 0 taken 784038 times.
✓ Branch 1 taken 40159221 times.
40943259 if(dying)
4196 {
4197
2/2
✓ Branch 0 taken 3960 times.
✓ Branch 1 taken 780078 times.
784038 if(clk2>=19)
4198 {
4199
2/2
✓ Branch 0 taken 1980 times.
✓ Branch 1 taken 1980 times.
3960 if(!(clk2&2))
4200 1980 sprite::drawzcboss(dest);
4201
4202 3960 return;
4203 }
4204
4205 780078 flip = 0;
4206 780078 tile = wpnsbuf[spr_death].tile;
4207
4208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780078 times.
780078 if ( do_animation )
4209 {
4210
2/2
✓ Branch 0 taken 775562 times.
✓ Branch 1 taken 4516 times.
780078 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4211 {
4212
2/2
✓ Branch 0 taken 4510 times.
✓ Branch 1 taken 6 times.
4516 if(clk2 > 2)
4213 {
4214 6 spr_death_anim_clk=0;
4215 6 clk2=1;
4216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(hp > -1000)
4217 6 death_sfx();
4218 6 }
4219
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 4256 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 76 times.
4516 if(clk2==1 && spr_death_anim_clk>-1)
4220 {
4221 76 ++clk2;
4222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm *= zc_max(1,txsz);
4224 76 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4226
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 2 times.
76 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4227 {
4228 2 spr_death_anim_clk=-1;
4229 2 clk2=1;
4230 2 }
4231 76 }
4232 4516 tile += spr_death_anim_frm;
4233 4516 }
4234
2/2
✓ Branch 0 taken 278586 times.
✓ Branch 1 taken 496976 times.
775562 else if(BSZ)
4235
2/2
✓ Branch 0 taken 219134 times.
✓ Branch 1 taken 59452 times.
278586 tile += zc_min((15-clk2)/3,4);
4236
4/4
✓ Branch 0 taken 331281 times.
✓ Branch 1 taken 165695 times.
✓ Branch 2 taken 165538 times.
✓ Branch 3 taken 165743 times.
496976 else if(clk2>6 && clk2<=12)
4237 165743 ++tile;
4238 780078 }
4239
4240
6/6
✓ Branch 0 taken 775562 times.
✓ Branch 1 taken 4516 times.
✓ Branch 2 taken 496976 times.
✓ Branch 3 taken 278586 times.
✓ Branch 4 taken 183872 times.
✓ Branch 5 taken 313104 times.
780078 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4241 466974 cs = wpnsbuf[spr_death].csets&15;
4242 else
4243 313104 cs = (((clk2+5)>>1)&3)+6;
4244 780078 }
4245
2/2
✓ Branch 0 taken 38944531 times.
✓ Branch 1 taken 1214690 times.
40159221 else if(hclk>0)
4246 {
4247 1214690 cs = getFlashingCSet();
4248 1214690 }
4249
4250 40939299 mapscr* scr = get_scr(screen_spawned);
4251
4252
3/4
✓ Branch 0 taken 2045619 times.
✓ Branch 1 taken 38893680 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7543 times.
40946842 if((scr->flags3&fINVISROOM) &&
4253
2/2
✓ Branch 0 taken 7543 times.
✓ Branch 1 taken 2038076 times.
2045619 !(current_item(itype_amulet)) &&
4254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7543 times.
7543 !(get_qr(qr_LENSSEESENEMIES) &&
4255 7543 lensclk) && type!=eeGANON)
4256 {
4257 7543 sprite::drawcloaked(dest);
4258 7543 }
4259 else
4260 {
4261
2/2
✓ Branch 0 taken 23473 times.
✓ Branch 1 taken 40908283 times.
40931756 if (is_hitflickerframe(true))
4262 {
4263
4/6
✓ Branch 0 taken 885 times.
✓ Branch 1 taken 22588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 885 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22588 times.
23473 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4264
1/2
✓ Branch 0 taken 23473 times.
✗ Branch 1 not taken.
23473 if (game->get_spriteflickercolor())
4265 {
4266 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4267 sprite_flicker_color = temp_flicker_color;
4268 sprite::drawzcboss(dest);
4269 }
4270 23473 }
4271 else
4272 40908283 sprite::drawzcboss(dest);
4273 }
4274
4275 40939299 cs=cshold;
4276 40943259 }
4277
4278
4279 // similar to the overblock function--can do up to a 32x32 sprite
4280 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
4281 323235 void enemy::drawblock(BITMAP *dest,int32_t mask)
4282 {
4283 323235 int32_t thold=tile;
4284 323235 int32_t t1=tile;
4285 323235 int32_t t2=tile+20;
4286 323235 int32_t t3=tile+1;
4287 323235 int32_t t4=tile+21;
4288
4289
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 323235 times.
323235 switch(mask)
4290 {
4291 case 1:
4292 enemy::drawzcboss(dest);
4293 break;
4294
4295 case 3:
4296 if(flip&2)
4297 zc_swap(t1,t2);
4298
4299 tile=t1;
4300 enemy::drawzcboss(dest);
4301 tile=t2;
4302 yofs+=16;
4303 enemy::drawzcboss(dest);
4304 yofs-=16;
4305 break;
4306
4307 case 5:
4308 t2=tile+1;
4309
4310 if(flip&1)
4311 zc_swap(t1,t2);
4312
4313 tile=t1;
4314 enemy::drawzcboss(dest);
4315 tile=t2;
4316 xofs+=16;
4317 enemy::drawzcboss(dest);
4318 xofs-=16;
4319 break;
4320
4321 case 15:
4322
2/2
✓ Branch 0 taken 316479 times.
✓ Branch 1 taken 6756 times.
323235 if(flip&1)
4323 {
4324 6756 zc_swap(t1,t3);
4325 6756 zc_swap(t2,t4);
4326 6756 }
4327
4328
1/2
✓ Branch 0 taken 323235 times.
✗ Branch 1 not taken.
323235 if(flip&2)
4329 {
4330 zc_swap(t1,t2);
4331 zc_swap(t3,t4);
4332 }
4333
4334 323235 tile=t1;
4335 323235 enemy::drawzcboss(dest);
4336 323235 tile=t2;
4337 323235 yofs+=16;
4338 323235 enemy::drawzcboss(dest);
4339 323235 yofs-=16;
4340 323235 tile=t3;
4341 323235 xofs+=16;
4342 323235 enemy::drawzcboss(dest);
4343 323235 tile=t4;
4344 323235 yofs+=16;
4345 323235 enemy::drawzcboss(dest);
4346 323235 xofs-=16;
4347 323235 yofs-=16;
4348 323235 break;
4349 }
4350
4351 323235 tile=thold;
4352 323235 }
4353
4354 20383527 void enemy::drawshadow(BITMAP *dest, bool translucent)
4355 {
4356
4/4
✓ Branch 0 taken 18372181 times.
✓ Branch 1 taken 2011346 times.
✓ Branch 2 taken 526918 times.
✓ Branch 3 taken 17845263 times.
20383527 if(dont_draw() || isSideViewGravity())
4357 {
4358 2538264 return;
4359 }
4360
4361
2/2
✓ Branch 0 taken 327632 times.
✓ Branch 1 taken 17517631 times.
17845263 if(dying)
4362 {
4363 327632 return;
4364 }
4365
4366 17517631 mapscr* scr = get_scr(screen_spawned);
4367
4/4
✓ Branch 0 taken 1718249 times.
✓ Branch 1 taken 15799382 times.
✓ Branch 2 taken 347010 times.
✓ Branch 3 taken 17170621 times.
17517631 if(((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
4368 17517631 (darkroom))
4369 {
4370 347010 return;
4371 }
4372 else
4373 {
4374
4/4
✓ Branch 0 taken 16571466 times.
✓ Branch 1 taken 599155 times.
✓ Branch 2 taken 16523997 times.
✓ Branch 3 taken 47469 times.
17170621 if(enemycanfall(id, false) && shadowtile == 0)
4375 47469 shadowtile = wpnsbuf[spr_shadow].tile;
4376
4377
5/6
✓ Branch 0 taken 16226739 times.
✓ Branch 1 taken 943882 times.
✓ Branch 2 taken 16226739 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15627584 times.
✓ Branch 5 taken 599155 times.
17170621 if(z>0 || fakez>0 || !enemycanfall(id, false))
4378 {
4379
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 1542762 times.
1543037 if(!shadow_overpit(this))
4380 1542762 sprite::drawshadow(dest,translucent);
4381 1543037 }
4382 }
4383 20383527 }
4384
4385 129181 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
4386 {
4387 129181 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
4388
4389
1/2
✓ Branch 0 taken 129181 times.
✗ Branch 1 not taken.
129181 if(sub!=NULL)
4390 {
4391 129181 xofs-=mx;
4392 129181 yofs-=my;
4393 129181 enemy::draw(sub);
4394 129181 xofs+=mx;
4395 129181 yofs+=my;
4396 129181 destroy_bitmap(sub);
4397 129181 }
4398 else
4399 enemy::draw(dest);
4400 129181 }
4401
4402 9 void enemy::init_size_flags()
4403 {
4404
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; }
4405
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
4406
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
4407
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
4408
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
4409
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
4410
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
4411
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
4412
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
4413 {
4414 yofs = (int32_t)d->yofs;
4415 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset);
4416 }
4417
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
4418 9 }
4419
4420 // override hit detection to check for invicibility, stunned, etc
4421 112664439 bool enemy::hit()
4422 {
4423
4/4
✓ Branch 0 taken 111337172 times.
✓ Branch 1 taken 1327267 times.
✓ Branch 2 taken 109522516 times.
✓ Branch 3 taken 1814656 times.
112664439 if(dying || hclk>0) return false;
4424 109522516 return sprite::hit();
4425 112664439 }
4426 730351 bool enemy::hit(sprite *s)
4427 {
4428
3/4
✓ Branch 0 taken 730351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 713374 times.
✓ Branch 3 taken 16977 times.
730351 if(!hit() || !s->hit()) return false;
4429 713374 return sprite::hit(s);
4430 730351 }
4431
4432 44723304 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
4433 {
4434
2/2
✓ Branch 0 taken 3973386 times.
✓ Branch 1 taken 40749918 times.
44723304 if(!hit()) return false;
4435 40749918 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
4436 44723304 }
4437 78011 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
4438 {
4439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78011 times.
78011 if(!hit()) return false;
4440 78011 return sprite::hit(tx,ty,txsz2,tysz2);
4441 78011 }
4442
4443 11190904 bool enemy::hit(weapon *w)
4444 {
4445
2/2
✓ Branch 0 taken 1196298 times.
✓ Branch 1 taken 9994606 times.
11190904 if(!hit()) return false;
4446
4447
2/2
✓ Branch 0 taken 6647382 times.
✓ Branch 1 taken 3347224 times.
9994606 if (replay_version_check(0, 14))
4448 {
4449
4/6
✓ Branch 0 taken 6422331 times.
✓ Branch 1 taken 225051 times.
✓ Branch 2 taken 6422331 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6422331 times.
✗ Branch 5 not taken.
6647382 if(!w->scriptcoldet || w->fallclk || w->drownclk)
4450 225051 return false;
4451 6422331 return sprite::hit(w);
4452 }
4453 3347224 return w->hit(this);
4454 11190904 }
4455
4456 38124564 bool enemy::can_pitfall(bool checkspawning)
4457 {
4458
4/4
✓ Branch 0 taken 36552358 times.
✓ Branch 1 taken 1572206 times.
✓ Branch 2 taken 36539384 times.
✓ Branch 3 taken 1585180 times.
38124564 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
4459
2/2
✓ Branch 0 taken 29877757 times.
✓ Branch 1 taken 6661627 times.
36539384 switch(guysbuf[id&0xFFF].type)
4460 {
4461 case eeAQUA:
4462 case eeDIG:
4463 case eeDONGO:
4464 case eeFAIRY:
4465 case eeGANON:
4466 case eeGHOMA:
4467 case eeGLEEOK:
4468 case eeGUY:
4469 case eeLANM:
4470 case eeMANHAN:
4471 case eeMOLD:
4472 case eeNONE:
4473 case eePATRA:
4474 case eeZORA:
4475 6661627 return false; //Disallowed types
4476 default:
4477 29877757 return true;
4478 }
4479 38124564 }
4480 //Handle death
4481 38009335 void enemy::try_death(bool force_kill)
4482 {
4483
8/8
✓ Branch 0 taken 37952766 times.
✓ Branch 1 taken 56569 times.
✓ Branch 2 taken 37952755 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 43653 times.
✓ Branch 5 taken 37909102 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 43652 times.
38009335 if(!dying && (force_kill || (hp<=0 && !immortal)))
4484 {
4485 43663 std::vector<int32_t> &ev = FFCore.eventData;
4486 43663 ev.clear();
4487 43663 ev.push_back(10000);
4488 43663 ev.push_back(getUID());
4489
4490 43663 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
4491 43663 bool isSaved = !ev[0];
4492 43663 ev.clear();
4493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43663 times.
43663 if(isSaved) return;
4494
4495
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 43613 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 44 times.
43663 if (itemguy && get_screen_state(screen_spawned).item_state == ScreenItemState::CarriedByEnemy)
4496 {
4497
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 44 times.
95 for(int32_t i=0; i<items.Count(); i++)
4498 {
4499
4/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 44 times.
51 if(((item*)items.spr(i))->pickup&ipENEMY && screen_spawned == ((item*)items.spr(i))->screen_spawned)
4500 {
4501
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 3 times.
44 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
4502 {
4503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
4504 {
4505 items.spr(i)->x = x+hxofs+(hit_width/2)-8;
4506 items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez;
4507 }
4508 else
4509 {
4510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(extend >= 3)
4511 {
4512 items.spr(i)->x = x+(txsz-1)*8;
4513 items.spr(i)->y = y-2+(tysz-1)*8;
4514 }
4515 else
4516 {
4517 3 items.spr(i)->x = x;
4518 3 items.spr(i)->y = y - 2;
4519 }
4520 }
4521 3 items.spr(i)->z = z;
4522 3 items.spr(i)->fakez = fakez;
4523 3 }
4524 else
4525 {
4526 41 items.spr(i)->x = x;
4527 41 items.spr(i)->y = y - 2;
4528 }
4529 44 }
4530 51 }
4531 44 }
4532
4533 43663 dying=true;
4534
4535
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 43631 times.
43663 if(fading==fade_flash_die)
4536 32 clk2=19+18*4;
4537 else
4538 {
4539 43631 clk2 = BSZ ? 15 : 19;
4540
4541
2/2
✓ Branch 0 taken 21062 times.
✓ Branch 1 taken 22569 times.
43631 if(fading!=fade_blue_poof)
4542 22569 fading=0;
4543 }
4544
4545
2/2
✓ Branch 0 taken 43613 times.
✓ Branch 1 taken 50 times.
43663 if(itemguy)
4546 {
4547 50 screen_item_set_state(screen_spawned, ScreenItemState::None);
4548 50 item_set=0;
4549 50 }
4550
6/6
✓ Branch 0 taken 42609 times.
✓ Branch 1 taken 1054 times.
✓ Branch 2 taken 33920 times.
✓ Branch 3 taken 8689 times.
✓ Branch 4 taken 1428 times.
✓ Branch 5 taken 32492 times.
43663 if (screen_spawned < 128 && count_enemy && !script_spawned)
4551 32492 game->guys[mapind(cur_map, screen_spawned)] -= 1;
4552 43663 }
4553 38009335 }
4554
4555 // --==**==--
4556
4557 // Movement routines that can be used by derived classes as needed
4558
4559 // --==**==--
4560
4561 556554 void enemy::fix_coords(bool bound)
4562 {
4563
1/2
✓ Branch 0 taken 556554 times.
✗ Branch 1 not taken.
556554 if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
4564
1/2
✓ Branch 0 taken 556554 times.
✗ Branch 1 not taken.
556554 if(moveflags & move_ignore_screenedge) bound = false;
4565
4566
2/2
✓ Branch 0 taken 81680 times.
✓ Branch 1 taken 474874 times.
556554 if(bound)
4567 {
4568 474874 int w = world_w;
4569 474874 int h = world_h;
4570
4571
1/2
✓ Branch 0 taken 474874 times.
✗ Branch 1 not taken.
474874 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
4572 {
4573
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474872 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
474874 x=vbound(x, 0, (( guysbuf[id].SIZEflags&OVERRIDE_TILE_WIDTH && !isflier(id) ) ? (w-((txsz-1)*16)) : w-16));
4574
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474872 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
474874 y=vbound(y, 0,(( guysbuf[id].SIZEflags&OVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (h-((txsz-1)*16)) : h-16));
4575 474874 }
4576 else
4577 {
4578 x=vbound(x, 0, w-16);
4579 y=vbound(y, 0, h-16);
4580 }
4581 474874 }
4582
4583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556554 times.
556554 if(!OUTOFBOUNDS(id, x, y))
4584 {
4585 556554 do_fix(x, 16, true);
4586
2/2
✓ Branch 0 taken 1139 times.
✓ Branch 1 taken 555415 times.
556554 if(isSideViewGravity())
4587 1139 do_fix(y,8,true);
4588 555415 else do_fix(y,16,true);
4589 556554 }
4590 556554 }
4591 9176 bool enemy::cannotpenetrate()
4592 {
4593
4/4
✓ Branch 0 taken 8995 times.
✓ Branch 1 taken 181 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 8957 times.
9176 return (type == eeAQUA || type == eeMANHAN || type == eeGHOMA);
4594 }
4595
4596 562 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
4597 {
4598 bool ok;
4599 562 int32_t dx = 0, dy = 0;
4600 562 int32_t sv = 8;
4601
4602 //Why is this here??? Why is it needed???
4603 562 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4604
4605
8/9
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 78 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 81 times.
✗ Branch 8 not taken.
562 switch(ndir)
4606 {
4607 case 8:
4608 case up:
4609
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
69 if(canfall(id) && isSideViewGravity())
4610 return false;
4611
4612 69 dy = dy1-s;
4613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 special = (special==spw_clipbottomright)?spw_none:special;
4614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4615 69 break;
4616
4617 case 12:
4618 case down:
4619
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
51 if(canfall(id) && isSideViewGravity())
4620 return false;
4621
4622 51 dy = dy2+s;
4623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4624 51 break;
4625
4626 case 14:
4627 case left:
4628 47 dx = dx1-s;
4629 47 sv = ((isSideViewGravity())?7:8);
4630
2/4
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
47 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4631
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 45 times.
47 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4632 47 break;
4633
4634 case 10:
4635 case right:
4636 85 dx = dx2+s;
4637 85 sv = ((isSideViewGravity())?7:8);
4638
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 79 times.
85 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4639 85 break;
4640
4641 case 9:
4642 case r_up:
4643 94 dx = dx2+s;
4644 94 dy = dy1-s;
4645
3/4
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 1 times.
187 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4647 94 break;
4648
4649 case 11:
4650 case r_down:
4651 78 dx = dx2+s;
4652 78 dx = dy2+s;
4653
3/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 1 times.
155 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4655 78 break;
4656
4657 case 13:
4658 case l_down:
4659 57 dx = dx1-s;
4660 57 dy = dy2+s;
4661
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4663 57 break;
4664
4665 case 15:
4666 case l_up:
4667 81 dx = dx1-s;
4668 81 dy = dy1-s;
4669
3/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 1 times.
161 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4671 81 break;
4672
4673 default:
4674 db=99;
4675 return true;
4676 }
4677
4678 562 return ok;
4679 562 }
4680
4681
4682
4683
4684 // returns true if next step is ok, false if there is something there
4685 7360028 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
4686 {
4687 7360028 bool ok = false; //initialise the var, son't just declare it
4688 7360028 int32_t dx = 0, dy = 0;
4689 7360028 int32_t sv = 8;
4690 7360028 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
4691 //Why is this here??? Why is it needed???
4692 7360028 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7360028 times.
7360028 int32_t usexoffs = (SIZEflags&OVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
4694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7360028 times.
7360028 int32_t useyoffs = (SIZEflags&OVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
4695
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7360015 times.
7360028 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4696
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7360015 times.
7360028 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4697 7360028 bool offgrid = OFFGRID_ENEMY;
4698
2/2
✓ Branch 0 taken 7291 times.
✓ Branch 1 taken 7352737 times.
7360028 if(!offgrid)
4699 {
4700 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
4701
1/2
✓ Branch 0 taken 7352737 times.
✗ Branch 1 not taken.
7352737 if(usehei<16)usehei=16;
4702
1/2
✓ Branch 0 taken 7352737 times.
✗ Branch 1 not taken.
7352737 if(usewid<16)usewid=16;
4703 7352737 }
4704
9/9
✓ Branch 0 taken 1331317 times.
✓ Branch 1 taken 1107763 times.
✓ Branch 2 taken 1227757 times.
✓ Branch 3 taken 1218339 times.
✓ Branch 4 taken 540601 times.
✓ Branch 5 taken 642269 times.
✓ Branch 6 taken 603869 times.
✓ Branch 7 taken 568437 times.
✓ Branch 8 taken 119676 times.
7360028 switch(ndir) //need to check every 8 pixels between two points
4705 {
4706 case 8:
4707 case up:
4708 {
4709
4/4
✓ Branch 0 taken 150808 times.
✓ Branch 1 taken 1180509 times.
✓ Branch 2 taken 150148 times.
✓ Branch 3 taken 660 times.
1331317 if(enemycanfall(id) && isSideViewGravity())
4710 660 return false;
4711
4712 1330657 dy = dy1-s;
4713
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1330177 times.
1330657 special = (special==spw_clipbottomright)?spw_none:special;
4714 1330657 tries = usewid/(offgrid ? 8 : 16);
4715
4716
2/2
✓ Branch 0 taken 1130437 times.
✓ Branch 1 taken 1331307 times.
2461744 for ( ; tries > 0; --tries )
4717 {
4718
2/2
✓ Branch 0 taken 197596 times.
✓ Branch 1 taken 1133711 times.
1331307 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
4719 1331307 try_x += (offgrid ? 8 : 16);
4720
2/2
✓ Branch 0 taken 1131087 times.
✓ Branch 1 taken 200220 times.
1331307 if (!ok) break;
4721 1131087 }
4722
2/2
✓ Branch 0 taken 1130437 times.
✓ Branch 1 taken 200220 times.
1330657 if(!ok) break;
4723
1/2
✓ Branch 0 taken 1130437 times.
✗ Branch 1 not taken.
1130437 if((usewid%16)>0) //Uneven width
4724 {
4725 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
4726 }
4727 1130437 break;
4728 }
4729 case 12:
4730 case down:
4731 {
4732
4/4
✓ Branch 0 taken 180701 times.
✓ Branch 1 taken 927062 times.
✓ Branch 2 taken 179975 times.
✓ Branch 3 taken 726 times.
1107763 if(enemycanfall(id) && isSideViewGravity())
4733 726 return false;
4734
4735 1107037 dy = dy2+s;
4736 1107037 tries = usewid/(offgrid ? 8 : 16);
4737
2/2
✓ Branch 0 taken 900644 times.
✓ Branch 1 taken 1107821 times.
2008465 for ( ; tries > 0; --tries )
4738 {
4739
3/4
✓ Branch 0 taken 205645 times.
✓ Branch 1 taken 902176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 902176 times.
1107821 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4740 1107821 try_x += (offgrid ? 8 : 16);
4741
2/2
✓ Branch 0 taken 901428 times.
✓ Branch 1 taken 206393 times.
1107821 if (!ok) break;
4742 901428 }
4743
2/2
✓ Branch 0 taken 900644 times.
✓ Branch 1 taken 206393 times.
1107037 if(!ok) break;
4744
1/2
✓ Branch 0 taken 900644 times.
✗ Branch 1 not taken.
900644 if((usewid%16)>0) //Uneven width
4745 {
4746 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4747 }
4748 900644 break;
4749 }
4750 case 14:
4751 case left:
4752 {
4753 1227757 dx = dx1-s;
4754 1227757 sv = ((isSideViewGravity())?7:0);
4755
4/4
✓ Branch 0 taken 1227134 times.
✓ Branch 1 taken 623 times.
✓ Branch 2 taken 1768 times.
✓ Branch 3 taken 1225366 times.
1227757 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4756 1227757 tries = usehei/(offgrid ? 8 : 16);
4757
2/2
✓ Branch 0 taken 1028543 times.
✓ Branch 1 taken 1228674 times.
2257217 for ( ; tries > 0; --tries )
4758 {
4759
2/2
✓ Branch 0 taken 198029 times.
✓ Branch 1 taken 1030645 times.
1228674 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
4760 1228674 try_y += (offgrid ? 8 : 16);
4761
2/2
✓ Branch 0 taken 1029460 times.
✓ Branch 1 taken 199214 times.
1228674 if (!ok) break;
4762 1029460 }
4763
2/2
✓ Branch 0 taken 1028543 times.
✓ Branch 1 taken 199214 times.
1227757 if(!ok) break;
4764
1/2
✓ Branch 0 taken 1028543 times.
✗ Branch 1 not taken.
1028543 if((usehei%16)>0) //Uneven height
4765 {
4766 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
4767 }
4768 1028543 break;
4769 }
4770 case 10:
4771 case right:
4772 {
4773 1218339 dx = dx2+s;
4774 1218339 sv = ((isSideViewGravity())?7:0);
4775 1218339 tries = usehei/(offgrid ? 8 : 16);
4776
2/2
✓ Branch 0 taken 1030011 times.
✓ Branch 1 taken 1219233 times.
2249244 for ( ; tries > 0; --tries )
4777 {
4778
3/4
✓ Branch 0 taken 186973 times.
✓ Branch 1 taken 1032260 times.
✓ Branch 2 taken 1032260 times.
✗ Branch 3 not taken.
1219233 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
4779 1219233 try_y += (offgrid ? 8 : 16);
4780
2/2
✓ Branch 0 taken 1030905 times.
✓ Branch 1 taken 188328 times.
1219233 if (!ok) break;
4781 1030905 }
4782
2/2
✓ Branch 0 taken 1030011 times.
✓ Branch 1 taken 188328 times.
1218339 if(!ok) break;
4783
1/2
✓ Branch 0 taken 1030011 times.
✗ Branch 1 not taken.
1030011 if((usehei%16)>0) //Uneven height
4784 {
4785 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
4786 }
4787 1030011 break;
4788 }
4789 case 9:
4790 case r_up:
4791 {
4792 540601 dx = dx2+s;
4793 540601 dy = dy1-s;
4794 540601 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4795 540601 sv = ((isSideViewGravity())?7:0);
4796
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 540601 times.
1064142 for ( ; tries_x > 0; --tries_x )
4797 {
4798 540601 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4799 540601 try_y = 0;
4800
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 540601 times.
1064142 for ( ; tries_y > 0; --tries_y )
4801 {
4802
4/4
✓ Branch 0 taken 532330 times.
✓ Branch 1 taken 8271 times.
✓ Branch 2 taken 526882 times.
✓ Branch 3 taken 5448 times.
1067483 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4803
2/2
✓ Branch 0 taken 2392 times.
✓ Branch 1 taken 524490 times.
526882 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4804 540601 try_y += (offgrid ? 8 : 16);
4805
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 17060 times.
540601 if (!ok) break;
4806 523541 }
4807
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 17060 times.
540601 if (!ok) break;
4808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 523541 times.
523541 if((usehei%16)>0) //Uneven height
4809 {
4810 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4811 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4812 }
4813 523541 try_x += (offgrid ? 8 : 16);
4814 523541 }
4815
2/2
✓ Branch 0 taken 523541 times.
✓ Branch 1 taken 17060 times.
540601 if(!ok) break;
4816
1/2
✓ Branch 0 taken 523541 times.
✗ Branch 1 not taken.
523541 if((usewid%16)>0) //Uneven width
4817 {
4818 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4819 try_y = 0;
4820 for ( ; tries_y > 0; --tries_y )
4821 {
4822 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4823 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4824 try_y += (offgrid ? 8 : 16);
4825 if (!ok) break;
4826 }
4827 if (!ok) break;
4828 if((usehei%16)>0) //Uneven height
4829 {
4830 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4831 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4832 }
4833 }
4834 523541 break;
4835 }
4836 case 11:
4837 case r_down:
4838 {
4839 642269 dx = dx2+s;
4840 642269 dx = dy2+s;
4841 642269 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4842 //sv = ((isSideViewGravity())?7:0);
4843
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 642269 times.
1269140 for ( ; tries_x > 0; --tries_x )
4844 {
4845 642269 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4846 642269 try_y = 0;
4847
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 642269 times.
1269140 for ( ; tries_y > 0; --tries_y )
4848 {
4849
4/4
✓ Branch 0 taken 640758 times.
✓ Branch 1 taken 1511 times.
✓ Branch 2 taken 627938 times.
✓ Branch 3 taken 12820 times.
1270207 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4850
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 627832 times.
627938 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4851 642269 try_y += (offgrid ? 8 : 16);
4852
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 15398 times.
642269 if (!ok) break;
4853 626871 }
4854
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 15398 times.
642269 if (!ok) break;
4855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626871 times.
626871 if((usehei%16)>0) //Uneven height
4856 {
4857 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4858 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4859 }
4860 626871 try_x += (offgrid ? 8 : 16);
4861 626871 }
4862
2/2
✓ Branch 0 taken 626871 times.
✓ Branch 1 taken 15398 times.
642269 if(!ok) break;
4863
1/2
✓ Branch 0 taken 626871 times.
✗ Branch 1 not taken.
626871 if((usewid%16)>0) //Uneven width
4864 {
4865 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4866 try_y = 0;
4867 for ( ; tries_y > 0; --tries_y )
4868 {
4869 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4870 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4871 try_y += (offgrid ? 8 : 16);
4872 if (!ok) break;
4873 }
4874 if (!ok) break;
4875 if((usehei%16)>0) //Uneven height
4876 {
4877 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4878 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4879 }
4880 }
4881 626871 break;
4882 }
4883 case 13:
4884 case l_down:
4885 {
4886 603869 dx = dx1-s;
4887 603869 dy = dy2+s;
4888 603869 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4889 //sv = ((isSideViewGravity())?7:0);
4890
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 603869 times.
1190662 for ( ; tries_x > 0; --tries_x )
4891 {
4892 603869 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4893 603869 try_y = 0;
4894
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 603869 times.
1190662 for ( ; tries_y > 0; --tries_y )
4895 {
4896
4/4
✓ Branch 0 taken 591935 times.
✓ Branch 1 taken 11934 times.
✓ Branch 2 taken 587661 times.
✓ Branch 3 taken 4274 times.
1191530 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4897
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 587093 times.
587661 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4898 603869 try_y += (offgrid ? 8 : 16);
4899
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 17076 times.
603869 if (!ok) break;
4900 586793 }
4901
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 17076 times.
603869 if (!ok) break;
4902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 586793 times.
586793 if((usehei%16)>0) //Uneven height
4903 {
4904 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4905 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4906 }
4907 586793 try_x += (offgrid ? 8 : 16);
4908 586793 }
4909
2/2
✓ Branch 0 taken 586793 times.
✓ Branch 1 taken 17076 times.
603869 if(!ok) break;
4910
1/2
✓ Branch 0 taken 586793 times.
✗ Branch 1 not taken.
586793 if((usewid%16)>0) //Uneven width
4911 {
4912 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4913 try_y = 0;
4914 for ( ; tries_y > 0; --tries_y )
4915 {
4916 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4917 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4918 try_y += (offgrid ? 8 : 16);
4919 if (!ok) break;
4920 }
4921 if (!ok) break;
4922 if((usehei%16)>0) //Uneven height
4923 {
4924 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4925 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4926 }
4927 }
4928 586793 break;
4929 }
4930 case 15:
4931 case l_up:
4932 {
4933 568437 dx = dx1-s;
4934 568437 dy = dy1-s;
4935 568437 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4936 568437 sv = ((isSideViewGravity())?7:0);
4937
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 568437 times.
1120931 for ( ; tries_x > 0; --tries_x )
4938 {
4939 568437 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4940 568437 try_y = 0;
4941
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 568437 times.
1120931 for ( ; tries_y > 0; --tries_y )
4942 {
4943
4/4
✓ Branch 0 taken 559771 times.
✓ Branch 1 taken 8666 times.
✓ Branch 2 taken 555802 times.
✓ Branch 3 taken 3969 times.
1124239 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4944
2/2
✓ Branch 0 taken 2439 times.
✓ Branch 1 taken 553363 times.
555802 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4945 568437 try_y += (offgrid ? 8 : 16);
4946
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 15943 times.
568437 if (!ok) break;
4947 552494 }
4948
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 15943 times.
568437 if (!ok) break;
4949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 552494 times.
552494 if((usehei%16)>0) //Uneven height
4950 {
4951 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4952 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4953 }
4954 552494 try_x += (offgrid ? 8 : 16);
4955 552494 }
4956
2/2
✓ Branch 0 taken 552494 times.
✓ Branch 1 taken 15943 times.
568437 if(!ok) break;
4957
1/2
✓ Branch 0 taken 552494 times.
✗ Branch 1 not taken.
552494 if((usewid%16)>0) //Uneven width
4958 {
4959 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4960 try_y = 0;
4961 for ( ; tries_y > 0; --tries_y )
4962 {
4963 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4964 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4965 try_y += (offgrid ? 8 : 16);
4966 if (!ok) break;
4967 }
4968 if (!ok) break;
4969 if((usehei%16)>0) //Uneven height
4970 {
4971 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4972 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4973 }
4974 }
4975 552494 break;
4976 }
4977 default:
4978 119676 db=99;
4979 119676 return true;
4980 }
4981
4982 7238966 return ok;
4983 7360028 }
4984
4985
4986 4652348 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
4987 {
4988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4652348 times.
4652348 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4652348 times.
4652348 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4990
1/2
✓ Branch 0 taken 4652348 times.
✗ Branch 1 not taken.
4652348 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
4991
1/2
✓ Branch 0 taken 4652348 times.
✗ Branch 1 not taken.
4652348 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
4992 4652348 --usewid;
4993 4652348 --usehei;
4994 4652348 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
4995 }
4996
4997 1244902 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
4998 {
4999 1244902 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
5000
5001
4/4
✓ Branch 0 taken 6819 times.
✓ Branch 1 taken 1238083 times.
✓ Branch 2 taken 5021 times.
✓ Branch 3 taken 1798 times.
1244902 if(special==spw_clipright&&ndir==right)
5002 {
5003 1798 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
5004 1798 }
5005
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1244897 times.
1244902 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
5006
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1244897 times.
1244902 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5007
1/2
✓ Branch 0 taken 1244902 times.
✗ Branch 1 not taken.
1244902 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5008
1/2
✓ Branch 0 taken 1244902 times.
✗ Branch 1 not taken.
1244902 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5009 1244902 --usewid;
5010 1244902 --usehei;
5011
2/2
✓ Branch 0 taken 717873 times.
✓ Branch 1 taken 527029 times.
1244902 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
5012 }
5013
5014 136347 bool enemy::canmove(int32_t ndir, bool kb)
5015 {
5016 136347 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
5017 }
5018
5019 // 8-directional
5020 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5021 {
5022 562 int32_t ndir=0;
5023
5024 // can move straight, check if it wants to turn
5025
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 13 times.
562 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
5026 {
5027
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(grumble && (zc_oldrand()&4)<grumble) //Homing
5028 {
5029 int32_t w = Lwpns.idFirst(wBait);
5030
5031 if(w>=0)
5032 {
5033 int32_t bx = Lwpns.spr(w)->x;
5034 int32_t by = Lwpns.spr(w)->y;
5035
5036 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5037
5038 if(abs(int32_t(y)-by)>14)
5039 {
5040 if(ndir>0) // Already left or right
5041 {
5042 // Making the diagonal directions
5043 ndir += (by<y) ? 2 : 4;
5044 }
5045 else
5046 {
5047 ndir = (by<y) ? up : down;
5048 }
5049 }
5050
5051 if(canmove(ndir,special,false))
5052 {
5053 dir=ndir;
5054 return;
5055 }
5056 }
5057 }
5058
5059 // Homing added.
5060
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(newhoming && (zc_oldrand()&255)<newhoming)
5061 {
5062 ndir = lined_up(8,true);
5063
5064 if(ndir>=0 && canmove(ndir,special,false))
5065 {
5066 dir=ndir;
5067 }
5068
5069 return;
5070 }
5071
5072 549 int32_t r=zc_oldrand();
5073
5074
2/4
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 549 times.
549 if(newrate>0 && !(r%newrate))
5075 {
5076 549 ndir = ((dir+((r&64)?-1:1))&7)+8;
5077 549 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5078
5079
2/2
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
549 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5080 525 dir=ndir;
5081
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 19 times.
24 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5082 19 dir=ndir2;
5083
5084
3/4
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 525 times.
✗ Branch 3 not taken.
549 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5085 // due to numerous lost fractional components. -L
5086 {
5087 x.doFloor();
5088 y.doFloor();
5089 }
5090 549 }
5091
5092 549 return;
5093 }
5094
5095 // can't move straight, must turn
5096 13 int32_t i=0;
5097
5098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 for(; i<32; i++) // Try random dir
5099 {
5100 20 ndir=(zc_oldrand()&7)+8;
5101
5102
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13 times.
20 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5103 13 break;
5104 7 }
5105
5106
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(i==32)
5107 {
5108 for(ndir=8; ndir<16; ndir++)
5109 {
5110 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5111 goto ok;
5112 }
5113
5114 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5115 }
5116
5117 ok:
5118 13 dir=ndir;
5119 13 x.doFloor();
5120 13 y.doFloor();
5121 562 }
5122
5123 580728 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5124 {
5125 580728 int32_t ndir=0;
5126
5127 // can move straight, check if it wants to turn
5128
2/2
✓ Branch 0 taken 548065 times.
✓ Branch 1 taken 32663 times.
580728 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
5129 {
5130
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 547858 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
548065 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
5131 {
5132 101 int32_t i = Lwpns.idFirst(wBait);
5133
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
5134 {
5135 weapon *w = (weapon*)Lwpns.spr(i);
5136 if (get_qr(qr_FIND_CLOSEST_BAIT))
5137 {
5138 int32_t currentrange;
5139 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5140 else currentrange = -1;
5141 int curid = i;
5142 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5143 for(; i<Lwpns.Count(); ++i)
5144 {
5145 weapon *lw = (weapon*)Lwpns.spr(i);
5146 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5147 {
5148 currentrange = distance(x, y, lw->x, lw->y);
5149 curid = i;
5150 }
5151 }
5152 i = curid;
5153 if (currentrange == -1) i = -1;
5154 }
5155 else
5156 {
5157 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5158 }
5159 if(i>=0)
5160 {
5161 int32_t bx = Lwpns.spr(i)->x;
5162 int32_t by = Lwpns.spr(i)->y;
5163
5164 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5165
5166 if(abs(int32_t(y)-by)>14)
5167 {
5168 if(ndir>0) // Already left or right
5169 {
5170 // Making the diagonal directions
5171 ndir += (by<y) ? 2 : 4;
5172 }
5173 else
5174 {
5175 ndir = (by<y) ? up : down;
5176 }
5177 }
5178 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5179 if(canmove(ndir,special,false))
5180 {
5181 dir=ndir;
5182 return;
5183 }
5184 }
5185 }
5186 101 }
5187
5188 // Homing added.
5189
4/4
✓ Branch 0 taken 29626 times.
✓ Branch 1 taken 518439 times.
✓ Branch 2 taken 15410 times.
✓ Branch 3 taken 14216 times.
548065 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
5190 {
5191 14216 ndir = lined_up(8,true);
5192
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14216 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14216 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5193
4/4
✓ Branch 0 taken 9445 times.
✓ Branch 1 taken 4771 times.
✓ Branch 2 taken 3593 times.
✓ Branch 3 taken 5852 times.
14216 if(ndir>=0 && canmove(ndir,special,false))
5194 {
5195 5852 dir=ndir;
5196 5852 }
5197
5198 14216 return;
5199 }
5200
5201 533849 int32_t r=zc_oldrand();
5202
5203
4/4
✓ Branch 0 taken 340048 times.
✓ Branch 1 taken 193801 times.
✓ Branch 2 taken 179767 times.
✓ Branch 3 taken 160281 times.
533849 if(newrate>0 && !(r%newrate))
5204 {
5205 160281 ndir = ((dir+((r&64)?-1:1))&7)+8;
5206 160281 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5207
5208
2/2
✓ Branch 0 taken 154477 times.
✓ Branch 1 taken 5804 times.
160281 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5209 154477 dir=ndir;
5210
2/2
✓ Branch 0 taken 857 times.
✓ Branch 1 taken 4947 times.
5804 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5211 4947 dir=ndir2;
5212
5213
4/4
✓ Branch 0 taken 154477 times.
✓ Branch 1 taken 5804 times.
✓ Branch 2 taken 147151 times.
✓ Branch 3 taken 7326 times.
160281 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5214 // due to numerous lost fractional components. -L
5215 {
5216 7326 x.doFloor();
5217 7326 y.doFloor();
5218 7326 }
5219 160281 }
5220
5221 533849 return;
5222 }
5223
5224 // can't move straight, must turn
5225 32663 int32_t i=0;
5226
5227 // TODO: speed this up!
5228
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 61154 times.
61224 for(; i<32; i++) // Try random dir
5229 {
5230 61154 ndir=(zc_oldrand()&7)+8;
5231
5232
2/2
✓ Branch 0 taken 28561 times.
✓ Branch 1 taken 32593 times.
61154 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5233 32593 break;
5234 28561 }
5235
5236
2/2
✓ Branch 0 taken 32593 times.
✓ Branch 1 taken 70 times.
32716 if(i==32)
5237 {
5238
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 53 times.
514 for(ndir=8; ndir<16; ndir++)
5239 {
5240
2/2
✓ Branch 0 taken 444 times.
✓ Branch 1 taken 17 times.
461 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5241 17 goto ok;
5242 444 }
5243
5244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5245 53 }
5246
5247 ok:
5248 32663 dir=ndir;
5249 32663 x.doFloor();
5250 32663 y.doFloor();
5251 580728 }
5252
5253 574253 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
5254 {
5255 574253 newdir_8(newrate,newhoming,special,0,-8,15,15);
5256 574253 }
5257
5258 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5259 {
5260 562 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
5261 562 }
5262
5263 // makes the enemy slide backwards when hit
5264 // sclk: first byte is clk, second byte is dir
5265 // makes the enemy slide backwards when hit
5266 // sclk: first byte is clk, second byte is dir
5267 15646054 int32_t enemy::slide()
5268 {
5269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15646054 times.
15646054 if(script_knockback_clk!=0) //scripted knockback
5270 {
5271 sclk = 0;
5272 return 1; //scripted knockback ran
5273 }
5274
5/6
✓ Branch 0 taken 102113 times.
✓ Branch 1 taken 15543941 times.
✓ Branch 2 taken 7857 times.
✓ Branch 3 taken 94256 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7857 times.
15646054 if(sclk==0 || (hp<=0 && !immortal))
5275 15551798 return 0;
5276
5277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94256 times.
94256 if(knockbackflags & FLAG_NOSLIDE)
5278 {
5279 sclk = 0;
5280 if(!OFFGRID_ENEMY)
5281 {
5282 //Fix to grid
5283 do_fix(x, 16, true);
5284 do_fix(y, 16, true);
5285 }
5286 return 0;
5287 }
5288
8/10
✓ Branch 0 taken 9554 times.
✓ Branch 1 taken 84702 times.
✓ Branch 2 taken 298 times.
✓ Branch 3 taken 9256 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 298 times.
✓ Branch 6 taken 7103 times.
✓ Branch 7 taken 2153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 298 times.
94256 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
5289 {
5290 2153 sclk=0;
5291 2153 return 0;
5292 }
5293
5294 92103 --sclk;
5295
5296
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10539 times.
✓ Branch 2 taken 12291 times.
✓ Branch 3 taken 31734 times.
✓ Branch 4 taken 35754 times.
92103 switch(sclk>>8)
5297 {
5298 case up:
5299 {
5300
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9449 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 10532 times.
10539 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
5301 {
5302 7 sclk=0;
5303 7 return 0;
5304 }
5305
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9442 times.
✓ Branch 2 taken 915 times.
✓ Branch 3 taken 175 times.
10532 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5306
5307 10357 break;
5308 }
5309 case down:
5310 {
5311
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12289 times.
12291 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
5312 {
5313 2 sclk=0;
5314 2 return 0;
5315 }
5316
4/4
✓ Branch 0 taken 1069 times.
✓ Branch 1 taken 11220 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 146 times.
12289 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5317
5318 12143 break;
5319 }
5320 case left:
5321 {
5322
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29380 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 31721 times.
31734 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
5323 {
5324 13 sclk=0;
5325 13 return 0;
5326 }
5327
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29367 times.
✓ Branch 2 taken 2116 times.
✓ Branch 3 taken 238 times.
31721 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
5328
5329 31483 break;
5330 }
5331 case right:
5332 {
5333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35754 times.
35754 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
5334 {
5335 sclk=0;
5336 return 0;
5337 }
5338
4/4
✓ Branch 0 taken 3288 times.
✓ Branch 1 taken 32466 times.
✓ Branch 2 taken 3018 times.
✓ Branch 3 taken 270 times.
35754 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5339 35484 break;
5340 }
5341 }
5342
5343 91252 int32_t move = knockbackSpeed;
5344
2/2
✓ Branch 0 taken 86369 times.
✓ Branch 1 taken 91252 times.
177621 while(move>0)
5345 {
5346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91252 times.
91252 int32_t thismove = zc_min(8, move);
5347 91252 move -= thismove;
5348 91252 hitdir = (sclk>>8);
5349
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10357 times.
✓ Branch 2 taken 12143 times.
✓ Branch 3 taken 31483 times.
✓ Branch 4 taken 35484 times.
91252 switch(sclk>>8)
5350 {
5351 case up:
5352 10357 y-=thismove;
5353 10357 break;
5354
5355 case down:
5356 12143 y+=thismove;
5357 12143 break;
5358
5359 case left:
5360 31483 x-=thismove;
5361 31483 break;
5362
5363 case right:
5364 35484 x+=thismove;
5365 35484 break;
5366 }
5367
2/2
✓ Branch 0 taken 86369 times.
✓ Branch 1 taken 4883 times.
91252 if(!canmove(sclk>>8,(zfix)0,0,true))
5368 {
5369
3/3
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 2906 times.
✓ Branch 2 taken 4 times.
4883 switch(sclk>>8)
5370 {
5371 case up:
5372 case down:
5373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973 times.
1973 if(y < 0)
5374 y = 0;
5375
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 1648 times.
1973 else if((int32_t(y)&15) > 7)
5376 325 y = TRUNCATE_TILE(int32_t(y)) + 16;
5377 else
5378 1648 y = TRUNCATE_TILE(int32_t(y));
5379
5380 1973 break;
5381
5382 case left:
5383 case right:
5384
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2902 times.
2906 if(x < 0)
5385 4 x = 0;
5386
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 2069 times.
2902 else if((int32_t(x)&15) > 7)
5387 833 x = TRUNCATE_TILE(int32_t(x)) + 16;
5388 else
5389 2069 x = TRUNCATE_TILE(int32_t(x));
5390
5391 2906 break;
5392 }
5393
5394 4883 sclk=0;
5395 4883 clk3=0;
5396 4883 break;
5397 }
5398 }
5399
5400
2/2
✓ Branch 0 taken 83889 times.
✓ Branch 1 taken 7363 times.
91252 if((sclk&255)==0)
5401 {
5402 //hitdir = -1;
5403 7363 sclk=0;
5404 7363 }
5405 91252 return 2;
5406 15646054 }
5407
5408 bool enemy::can_slide()
5409 {
5410 if(sclk==0 || (hp<=0 && !immortal))
5411 return false;
5412
5413 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
5414 {
5415 return false;
5416 }
5417
5418 return true;
5419 }
5420
5421 bool enemy::fslide()
5422 {
5423 if(sclk==0 || (hp<=0 && !immortal))
5424 return false;
5425
5426 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
5427 {
5428 sclk=0;
5429 return false;
5430 }
5431
5432 --sclk;
5433
5434 switch(sclk>>8)
5435 {
5436 case up:
5437 if(y<=16)
5438 {
5439 sclk=0;
5440 return false;
5441 }
5442
5443 break;
5444
5445 case down:
5446 if(y>=world_h-16)
5447 {
5448 sclk=0;
5449 return false;
5450 }
5451
5452 break;
5453
5454 case left:
5455 if(x<=16)
5456 {
5457 sclk=0;
5458 return false;
5459 }
5460
5461 break;
5462
5463 case right:
5464 if(x>=world_w-16)
5465 {
5466 sclk=0;
5467 return false;
5468 }
5469
5470 break;
5471 }
5472 hitdir = (sclk>>8);
5473 switch(sclk>>8)
5474 {
5475 case up:
5476 y-=4;
5477 break;
5478
5479 case down:
5480 y+=4;
5481 break;
5482
5483 case left:
5484 x-=4;
5485 break;
5486
5487 case right:
5488 x+=4;
5489 break;
5490 }
5491
5492 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
5493 {
5494 switch(sclk>>8)
5495 {
5496 case up:
5497 case down:
5498 if((int32_t(y)&15) > 7)
5499 y = TRUNCATE_TILE(int32_t(y)) + 16;
5500 else
5501 y = TRUNCATE_TILE(int32_t(y));
5502
5503 break;
5504
5505 case left:
5506 case right:
5507 if((int32_t(x)&15) > 7)
5508 x = TRUNCATE_TILE(int32_t(x)) + 16;
5509 else
5510 x = TRUNCATE_TILE(int32_t(x));
5511
5512 break;
5513 }
5514
5515 sclk=0;
5516 clk3=0;
5517 }
5518
5519 if((sclk&255)==0)
5520 sclk=0;
5521
5522 return true;
5523 }
5524
5525 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
5526 {
5527 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
5528 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
5529 bool ret = sprite::knockback(time, dir, speed);
5530 if(ret) sclk = 0; //kill engine knockback if interrupted
5531 //! Perhaps also set hitdir here, if needed for timing? -Z
5532 return ret;
5533 }
5534
5535 38009324 bool enemy::runKnockback()
5536 {
5537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38009324 times.
38009324 if((script_knockback_clk&0xFF)==0)
5538 {
5539 38009324 script_knockback_clk = 0;
5540 38009324 return false;
5541 }
5542 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
5543 {
5544 return false;
5545 }
5546 int32_t move = script_knockback_speed;
5547 int32_t kb_dir = script_knockback_clk>>8;
5548 --script_knockback_clk;
5549
5550 while(move>0)
5551 {
5552 int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
5553 move -= thismove;
5554 hitdir = kb_dir;
5555 switch(kb_dir)
5556 {
5557 case r_up:
5558 case l_up:
5559 case up:
5560 y-=thismove;
5561 break;
5562
5563 case r_down:
5564 case l_down:
5565 case down:
5566 y+=thismove;
5567 break;
5568 }
5569 switch(kb_dir)
5570 {
5571 case l_up:
5572 case l_down:
5573 case left:
5574 x-=thismove;
5575 break;
5576
5577 case r_up:
5578 case r_down:
5579 case right:
5580 x+=thismove;
5581 break;
5582 }
5583 if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK))
5584 {
5585 if(!canmove(kb_dir,(zfix)0,0,true))
5586 {
5587 script_knockback_clk=0;
5588 clk3=0;
5589 //Fix to grid
5590 switch(kb_dir)
5591 {
5592 case up:
5593 case down:
5594 break;
5595 default:
5596 if(x < 0)
5597 x = 0;
5598 else if((int32_t(x)&15) > 7)
5599 x = TRUNCATE_TILE(int32_t(x)) + 16;
5600 else
5601 x = TRUNCATE_TILE(int32_t(x));
5602 break;
5603 }
5604 switch(kb_dir)
5605 {
5606 case left:
5607 case right:
5608 break;
5609 default:
5610 if(y < 0)
5611 y = 0;
5612 else if((int32_t(y)&15) > 7)
5613 y = TRUNCATE_TILE(int32_t(y)) + 16;
5614 else
5615 y = TRUNCATE_TILE(int32_t(y));
5616 break;
5617 }
5618 break;
5619 }
5620 }
5621 else
5622 {
5623 if(!scr_canplace(x,y,0,true))
5624 {
5625 script_knockback_clk=0;
5626 clk3=0;
5627 //Fix to grid
5628 if (OFFGRID_ENEMY)
5629 {
5630 switch(kb_dir)
5631 {
5632 case up:
5633 case down:
5634 break;
5635 default:
5636 if(x < 0)
5637 x = 0;
5638 else if((int32_t(x)&7) > 3)
5639 x = TRUNCATE_HALF_TILE(int32_t(x)) + 8;
5640 else
5641 x = TRUNCATE_HALF_TILE(int32_t(x));
5642 break;
5643 }
5644 switch(kb_dir)
5645 {
5646 case left:
5647 case right:
5648 break;
5649 default:
5650 if(y < 0)
5651 y = 0;
5652 else if((int32_t(y)&7) > 3)
5653 y = TRUNCATE_HALF_TILE(int32_t(y)) + 8;
5654 else
5655 y = TRUNCATE_HALF_TILE(int32_t(y));
5656 break;
5657 }
5658 }
5659 else
5660 {
5661 switch(kb_dir)
5662 {
5663 case up:
5664 case down:
5665 break;
5666 default:
5667 if(x < 0)
5668 x = 0;
5669 else if((int32_t(x)&15) > 7)
5670 x = TRUNCATE_TILE(int32_t(x)) + 16;
5671 else
5672 x = TRUNCATE_TILE(int32_t(x));
5673 break;
5674 }
5675 switch(kb_dir)
5676 {
5677 case left:
5678 case right:
5679 break;
5680 default:
5681 if(y < 0)
5682 y = 0;
5683 else if((int32_t(y)&15) > 7)
5684 y = TRUNCATE_TILE(int32_t(y)) + 16;
5685 else
5686 y = TRUNCATE_TILE(int32_t(y));
5687 break;
5688 }
5689 }
5690 break;
5691 }
5692
5693 }
5694 }
5695 return true;
5696 38009324 }
5697 // changes enemy's direction, checking restrictions
5698 // rate: 0 = no random changes, 16 = always random change
5699 // homing: 0 = none, 256 = always
5700 // grumble 0 = none, 4 = strongest appetite
5701 521075 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
5702 {
5703 521075 int32_t ndir=-1;
5704
5705
4/4
✓ Branch 0 taken 110060 times.
✓ Branch 1 taken 411015 times.
✓ Branch 2 taken 37882 times.
✓ Branch 3 taken 72178 times.
521075 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble))
5706 {
5707 72178 int32_t i = Lwpns.idFirst(wBait);
5708
1/2
✓ Branch 0 taken 72178 times.
✗ Branch 1 not taken.
72178 if(i >= 0) //idfirst returns -1 if it can't find any
5709 {
5710 weapon *w = (weapon*)Lwpns.spr(i);
5711 if (get_qr(qr_FIND_CLOSEST_BAIT))
5712 {
5713 int32_t currentrange;
5714 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5715 else currentrange = -1;
5716 int curid = i;
5717 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5718 for(; i<Lwpns.Count(); ++i)
5719 {
5720 weapon *lw = (weapon*)Lwpns.spr(i);
5721 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5722 {
5723 currentrange = distance(x, y, lw->x, lw->y);
5724 curid = i;
5725 }
5726 }
5727 i = curid;
5728 if (currentrange == -1) i = -1;
5729 }
5730 else
5731 {
5732 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5733 }
5734 if (i >= 0)
5735 {
5736 int32_t bx = Lwpns.spr(i)->x;
5737 int32_t by = Lwpns.spr(i)->y;
5738
5739 if(abs(int32_t(y)-by)>14)
5740 {
5741 ndir = (by<y) ? up : down;
5742 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5743 if(canmove(ndir,special,false))
5744 {
5745 dir=ndir;
5746 return;
5747 }
5748 }
5749
5750 ndir = (bx<x) ? left : right;
5751 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5752 if(canmove(ndir,special,false))
5753 {
5754 dir=ndir;
5755 return;
5756 }
5757 }
5758 }
5759 72178 }
5760
5761
2/2
✓ Branch 0 taken 352951 times.
✓ Branch 1 taken 168124 times.
521075 if((zc_oldrand()&255)<abs(newhoming))
5762 {
5763 168124 ndir = lined_up(8,false);
5764
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 168124 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
168124 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5765
4/4
✓ Branch 0 taken 45390 times.
✓ Branch 1 taken 122734 times.
✓ Branch 2 taken 5720 times.
✓ Branch 3 taken 39670 times.
168124 if(ndir>=0 && canmove(ndir,special,false))
5766 {
5767 39670 dir=ndir;
5768 39670 return;
5769 }
5770 128454 }
5771
5772 481405 int32_t i=0;
5773
5774
2/2
✓ Branch 0 taken 3340 times.
✓ Branch 1 taken 1181128 times.
1184468 for(; i<32; i++)
5775 {
5776 1181128 int32_t r=zc_oldrand();
5777
5778
2/2
✓ Branch 0 taken 345129 times.
✓ Branch 1 taken 835999 times.
1181128 if((r&15)<newrate)
5779 345129 ndir=(r>>4)&3;
5780 else
5781 835999 ndir=dir;
5782
5783
2/2
✓ Branch 0 taken 703063 times.
✓ Branch 1 taken 478065 times.
1181128 if(canmove(ndir,special,false))
5784 478065 break;
5785 703063 }
5786
5787
2/2
✓ Branch 0 taken 478065 times.
✓ Branch 1 taken 3340 times.
482163 if(i==32)
5788 {
5789
2/2
✓ Branch 0 taken 8939 times.
✓ Branch 1 taken 758 times.
9697 for(ndir=0; ndir<4; ndir++)
5790 {
5791
2/2
✓ Branch 0 taken 6357 times.
✓ Branch 1 taken 2582 times.
8939 if(canmove(ndir,special,false))
5792 2582 goto ok;
5793 6357 }
5794
5795
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 698 times.
758 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5796 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
5797 758 }
5798
5799 ok:
5800 481405 dir = ndir;
5801 521075 }
5802
5803 2682 void enemy::newdir()
5804 {
5805 2682 newdir(4,0,spw_none);
5806 2682 }
5807
5808 zfix enemy::distance_left()
5809 {
5810 int32_t a2=x.getInt();
5811 int32_t b2=y.getInt();
5812
5813 switch(dir)
5814 {
5815 case up:
5816 return (zfix)(b2&0xF);
5817
5818 case down:
5819 return (zfix)(16-(b2&0xF));
5820
5821 case left:
5822 return (zfix)(a2&0xF);
5823
5824 case right:
5825 return (zfix)(16-(a2&0xF));
5826 }
5827
5828 return (zfix)0;
5829 }
5830
5831 // keeps walking around
5832 391434 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
5833 {
5834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 391434 times.
391434 if(slide())
5835 return;
5836
5837
8/12
✓ Branch 0 taken 387600 times.
✓ Branch 1 taken 3834 times.
✓ Branch 2 taken 387600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 383173 times.
✓ Branch 5 taken 4427 times.
✓ Branch 6 taken 383173 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 383173 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 383173 times.
391434 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
5838 8261 return;
5839
5840
2/2
✓ Branch 0 taken 26115 times.
✓ Branch 1 taken 357058 times.
383173 if(clk3<=0)
5841 {
5842 26115 fix_coords(true);
5843 26115 newdir(newrate,newhoming,special);
5844
5845
1/2
✓ Branch 0 taken 26115 times.
✗ Branch 1 not taken.
26115 if(step==0)
5846 clk3=0;
5847 else
5848 26115 clk3=int32_t(16.0/step);
5849 26115 }
5850
2/2
✓ Branch 0 taken 357013 times.
✓ Branch 1 taken 45 times.
357058 else if(scored)
5851 {
5852 45 dir^=1;
5853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5854 else clk3=32767;
5855 45 }
5856
5857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383173 times.
383173 if (step != 0) --clk3;
5858 383173 move(step);
5859 391434 }
5860
5861 void enemy::constant_walk()
5862 {
5863 constant_walk(4,0,spw_none);
5864 }
5865
5866 35220 int32_t enemy::pos(int32_t newx,int32_t newy)
5867 {
5868 35220 return (newy<<8)+newx;
5869 }
5870
5871 // for variable step rates
5872 473814 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
5873 {
5874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
473814 if(slide())
5875 return;
5876
5877
10/14
✓ Branch 0 taken 473814 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 473814 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 465189 times.
✓ Branch 5 taken 8625 times.
✓ Branch 6 taken 455915 times.
✓ Branch 7 taken 9274 times.
✓ Branch 8 taken 418370 times.
✓ Branch 9 taken 37545 times.
✓ Branch 10 taken 418370 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 418370 times.
✗ Branch 13 not taken.
473814 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
5878 55444 return;
5879
5880 418370 zfix dx = (zfix)0;
5881 418370 zfix dy = (zfix)0;
5882
5883
5/9
✓ Branch 0 taken 93441 times.
✓ Branch 1 taken 97752 times.
✓ Branch 2 taken 111603 times.
✓ Branch 3 taken 113743 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1831 times.
418370 switch(dir)
5884 {
5885 case 8:
5886 case up:
5887 93441 dy-=step;
5888 93441 break;
5889
5890 case 12:
5891 case down:
5892 97752 dy+=step;
5893 97752 break;
5894
5895 case 14:
5896 case left:
5897 111603 dx-=step;
5898 111603 break;
5899
5900 case 10:
5901 case right:
5902 113743 dx+=step;
5903 113743 break;
5904
5905 case 15:
5906 case l_up:
5907 dx-=step;
5908 dy-=step;
5909 break;
5910
5911 case 9:
5912 case r_up:
5913 dx+=step;
5914 dy-=step;
5915 break;
5916
5917 case 13:
5918 case l_down:
5919 dx-=step;
5920 dy+=step;
5921 break;
5922
5923 case 11:
5924 case r_down:
5925 dx+=step;
5926 dy+=step;
5927 break;
5928 }
5929
5930
8/8
✓ Branch 0 taken 204198 times.
✓ Branch 1 taken 214172 times.
✓ Branch 2 taken 22777 times.
✓ Branch 3 taken 181421 times.
✓ Branch 4 taken 11556 times.
✓ Branch 5 taken 11221 times.
✓ Branch 6 taken 405927 times.
✓ Branch 7 taken 12443 times.
418370 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
5931 406814 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
5932 {
5933 12443 fix_coords();
5934 12443 newdir(newrate,newhoming,special);
5935 12443 clk3=pos(x,y);
5936 12443 }
5937
5938 418370 move(step);
5939 473814 }
5940
5941 // pauses for a while after it makes a complete move (to a new square)
5942 12334139 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
5943 {
5944
4/4
✓ Branch 0 taken 79892 times.
✓ Branch 1 taken 12254247 times.
✓ Branch 2 taken 67060 times.
✓ Branch 3 taken 12832 times.
12334139 if(sclk && clk2)
5945 {
5946 12832 clk3=0;
5947 12832 }
5948
5949
11/14
✓ Branch 0 taken 12261115 times.
✓ Branch 1 taken 73024 times.
✓ Branch 2 taken 12261115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12261115 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11793947 times.
✓ Branch 7 taken 467168 times.
✓ Branch 8 taken 11656198 times.
✓ Branch 9 taken 137749 times.
✓ Branch 10 taken 11651662 times.
✓ Branch 11 taken 4536 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 11651662 times.
12334139 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5950 {
5951 682477 return;
5952 }
5953
5954
2/2
✓ Branch 0 taken 2132955 times.
✓ Branch 1 taken 9518707 times.
11651662 if(clk2>0)
5955 {
5956 2132955 --clk2;
5957 2132955 return;
5958 }
5959
5960
2/2
✓ Branch 0 taken 411244 times.
✓ Branch 1 taken 9107463 times.
9518707 if(clk3<=0)
5961 {
5962 411244 fix_coords(true);
5963 411244 newdir(newrate,newhoming,special);
5964 411244 clk3=int32_t(16.0/step);
5965
2/2
✓ Branch 0 taken 411047 times.
✓ Branch 1 taken 197 times.
411244 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
5966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 411244 times.
411244 if(clk2<0)
5967 {
5968 clk2=0;
5969 }
5970
2/2
✓ Branch 0 taken 54771 times.
✓ Branch 1 taken 356473 times.
411244 else if((zc_oldrand()&15)<newhrate)
5971 {
5972 54771 clk2=haltcnt;
5973 54771 return;
5974 }
5975 356473 }
5976
2/2
✓ Branch 0 taken 9104303 times.
✓ Branch 1 taken 3160 times.
9107463 else if(scored)
5977 {
5978 3160 dir^=1;
5979
5980
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3155 times.
3160 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5981 5 else clk3=32767;
5982 3160 }
5983
5984
2/2
✓ Branch 0 taken 76939 times.
✓ Branch 1 taken 9386997 times.
9463936 if (step != 0) --clk3;
5985 9463936 move(step);
5986 12334139 }
5987
5988 // 8-directional movement, aligns to 8 pixels
5989 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
5990 {
5991 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5992 return;
5993
5994 if(clk3<=0)
5995 {
5996 newdir_8(newrate,newhoming,special);
5997 clk3=int32_t(8.0/step);
5998 if (step == 0) clk3 = 32767;
5999 }
6000
6001 if (step != 0) --clk3;
6002 move(step);
6003 }
6004 // 8-directional movement, aligns to 8 pixels
6005 242393 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
6006 {
6007
6/12
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242393 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242393 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 242393 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 242393 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 242393 times.
242393 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6008 return;
6009
6010
2/2
✓ Branch 0 taken 226158 times.
✓ Branch 1 taken 16235 times.
242393 if(clk3<=0)
6011 {
6012 16235 newdir_8(newrate,newhoming,special);
6013 16235 clk3=int32_t(8.0/step);
6014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16235 times.
16235 if (step == 0) clk3 = 32767;
6015 16235 }
6016
6017
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if (step != 0) --clk3;
6018 242393 move(step);
6019 242393 }
6020
6021 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
6022 {
6023 if(clk<0 || dying || stunclk || watch || frozenclock)
6024 return;
6025
6026 if(!canmove(dir,step,special,false))
6027 clk3=0;
6028
6029 if(clk2>0)
6030 {
6031 --clk2;
6032 return;
6033 }
6034
6035 if(clk3<=0)
6036 {
6037 newdir_8(newrate,newhoming,special);
6038 clk3=newclk;
6039
6040 if(clk2<0)
6041 {
6042 clk2=0;
6043 }
6044 else if((zc_oldrand()&15)<newhrate)
6045 {
6046 newdir_8(newrate,newhoming,special);
6047 clk2=haltcnt;
6048 return;
6049 }
6050 }
6051
6052 --clk3;
6053 move(step);
6054 }
6055
6056 // 8-directional movement, no alignment
6057 4721045 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
6058 {
6059
9/12
✓ Branch 0 taken 4511760 times.
✓ Branch 1 taken 209285 times.
✓ Branch 2 taken 4511760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4485139 times.
✓ Branch 5 taken 26621 times.
✓ Branch 6 taken 4474092 times.
✓ Branch 7 taken 11047 times.
✓ Branch 8 taken 4474092 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4474092 times.
4721045 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6060 246953 return;
6061
6062
2/2
✓ Branch 0 taken 4443604 times.
✓ Branch 1 taken 30488 times.
4474092 if(!canmove(dir,step,special,false))
6063 30488 clk3=0;
6064
6065
2/2
✓ Branch 0 taken 3916074 times.
✓ Branch 1 taken 558018 times.
4474092 if(clk3<=0)
6066 {
6067 558018 newdir_8(newrate,newhoming,special);
6068 558018 clk3=newclk;
6069 558018 }
6070
6071 4474092 --clk3;
6072 4474092 move(step);
6073 4721045 }
6074
6075 // same as above but with variable enemy size
6076 94563 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6077 {
6078
8/12
✓ Branch 0 taken 93367 times.
✓ Branch 1 taken 1196 times.
✓ Branch 2 taken 93367 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93367 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 93316 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 93316 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 93316 times.
94563 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6079 1247 return;
6080
6081
2/2
✓ Branch 0 taken 91982 times.
✓ Branch 1 taken 1334 times.
93316 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
6082 1334 clk3=0;
6083
6084
2/2
✓ Branch 0 taken 86841 times.
✓ Branch 1 taken 6475 times.
93316 if(clk3<=0)
6085 {
6086 6475 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
6087 6475 clk3=newclk;
6088 6475 }
6089
6090 93316 --clk3;
6091 93316 move(step);
6092 94563 }
6093
6094 // the variable speed floater movement
6095 // ms is max speed
6096 // ss is step speed
6097 // s is step count
6098 // p is pause count
6099 // g is graduality :)
6100 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
6101 4019514 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
6102 {
6103 4019514 ++clk2;
6104 4019514 byte over_pit = overpit(this);
6105
6106
4/4
✓ Branch 0 taken 1114794 times.
✓ Branch 1 taken 2904720 times.
✓ Branch 2 taken 1114527 times.
✓ Branch 3 taken 267 times.
4019514 if(dmisc1 && over_pit) p = 0;
6107
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 56650 times.
✓ Branch 2 taken 1586380 times.
✓ Branch 3 taken 2243416 times.
✓ Branch 4 taken 133068 times.
4019514 switch(movestatus)
6108 {
6109 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
6110 //! if the conditions prevent it, we jump back to case 2.
6111 case 0: // paused
6112
2/2
✓ Branch 0 taken 55199 times.
✓ Branch 1 taken 1451 times.
56650 if(clk2>=p)
6113 {
6114 1451 movestatus=1;
6115 1451 clk2=0;
6116 1451 }
6117
6118 56650 break;
6119
6120 case 1: // speeding up
6121
1/2
✓ Branch 0 taken 1586380 times.
✗ Branch 1 not taken.
1586380 if (s >= 0)
6122 {
6123
2/2
✓ Branch 0 taken 1575074 times.
✓ Branch 1 taken 11306 times.
1586380 if(clk2<g*s)
6124 {
6125
2/2
✓ Branch 0 taken 1473474 times.
✓ Branch 1 taken 101600 times.
1575074 if(!((clk2-1)%g))
6126 101600 step+=ss;
6127 1575074 }
6128 else
6129 {
6130 11306 movestatus=2;
6131 11306 clk2=0;
6132 }
6133 1586380 }
6134 else
6135 {
6136 if(step < ms)
6137 {
6138 if(!((clk2-1)%g))
6139 {
6140 step+=ss;
6141 if (step >= ms) step = ms;
6142 }
6143 }
6144 else
6145 {
6146 step = ms;
6147 movestatus=2;
6148 clk2=0;
6149 }
6150 }
6151
6152 1586380 break;
6153
6154 case 2: // normal
6155 2243416 step=ms;
6156
6157
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2243416 times.
✓ Branch 2 taken 481019 times.
✓ Branch 3 taken 1762397 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1762397 times.
✓ Branch 6 taken 1760147 times.
✓ Branch 7 taken 2250 times.
2243416 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
6158 {
6159
1/2
✓ Branch 0 taken 2250 times.
✗ Branch 1 not taken.
2250 if (s >= 0) step=ss*s;
6160 else step=ms;
6161 2250 movestatus=3;
6162 2250 clk2=0;
6163 2250 }
6164
6165 2243416 break;
6166
6167 case 3: // slowing down
6168
1/2
✓ Branch 0 taken 133068 times.
✗ Branch 1 not taken.
133068 if (s >= 0)
6169 {
6170
2/2
✓ Branch 0 taken 131387 times.
✓ Branch 1 taken 1681 times.
133068 if(clk2<=g*s)
6171 {
6172 { //don't slow down over pits
6173
6174
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 131120 times.
131387 if(over_pit)
6175 {
6176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267 times.
267 if(dmisc1)
6177 {
6178 step=ms;
6179 }
6180 267 }
6181 else //can slow down
6182 {
6183
4/4
✓ Branch 0 taken 8088 times.
✓ Branch 1 taken 123032 times.
✓ Branch 2 taken 7720 times.
✓ Branch 3 taken 368 times.
131120 if(!(clk2%g) && !dmisc1)
6184 7720 step-=ss;
6185 }
6186 }
6187
6188
6189 131387 }
6190 else
6191 {
6192 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6193 //this doesn't help keese, as they have a z of 0.
6194 //they always nee to run this check.
6195 {
6196
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1681 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1681 if(over_pit &&!dmisc1)
6197 {
6198 --clk2; //if over a pit, don't land, and revert clock change
6199 }
6200 else //can land safely
6201 {
6202 1681 movestatus=0;
6203
3/4
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 566 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1115 times.
1681 if(dmisc1&&!over_pit)
6204 1115 step=0;
6205 1681 clk2=0;
6206 }
6207 }
6208
6209 }
6210 133068 }
6211 else
6212 {
6213 if(step > 0)
6214 {
6215 if(over_pit)
6216 {
6217 if(dmisc1)
6218 {
6219 step=ms;
6220 }
6221 }
6222 else //can slow down
6223 {
6224 if(!(clk2%g))
6225 step-=ss;
6226 }
6227 }
6228 else
6229 {
6230 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6231 //this doesn't help keese, as they have a z of 0.
6232 //they always nee to run this check.
6233 if(over_pit)
6234 {
6235 step+=ss; //if over a pit, don't land, and revert clock change
6236 }
6237 else //can land safely
6238 {
6239 movestatus=0;
6240 step=0;
6241 clk2=0;
6242 }
6243 }
6244 }
6245
6246 133068 break;
6247 }
6248
6249
2/2
✓ Branch 0 taken 2252472 times.
✓ Branch 1 taken 1767042 times.
4019514 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
6250 4019514 }
6251
6252 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
6253 {
6254 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
6255 }
6256
6257 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
6258 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
6259 927949 int32_t enemy::lined_up(int32_t range, bool dir8)
6260 {
6261 927949 int32_t lx = Hero.getX();
6262 927949 int32_t ly = Hero.getY();
6263
6264
2/2
✓ Branch 0 taken 38914 times.
✓ Branch 1 taken 889035 times.
927949 if(abs(lx-int32_t(x))<=range)
6265 {
6266
2/2
✓ Branch 0 taken 16351 times.
✓ Branch 1 taken 22563 times.
38914 if(ly<y)
6267 {
6268 16351 return up;
6269 }
6270
6271 22563 return down;
6272 }
6273
6274
2/2
✓ Branch 0 taken 56361 times.
✓ Branch 1 taken 832674 times.
889035 if(abs(ly-int32_t(y))<=range)
6275 {
6276
2/2
✓ Branch 0 taken 30301 times.
✓ Branch 1 taken 26060 times.
56361 if(lx<x)
6277 {
6278 30301 return left;
6279 }
6280
6281 26060 return right;
6282 }
6283
6284
2/2
✓ Branch 0 taken 160084 times.
✓ Branch 1 taken 672590 times.
832674 if(dir8)
6285 {
6286
2/2
✓ Branch 0 taken 253848 times.
✓ Branch 1 taken 418742 times.
672590 if(abs(lx-x)-abs(ly-y)<=range)
6287 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
6288 {
6289
2/2
✓ Branch 0 taken 106080 times.
✓ Branch 1 taken 147768 times.
253848 if(ly<y)
6290 {
6291
2/2
✓ Branch 0 taken 56676 times.
✓ Branch 1 taken 49404 times.
106080 if(lx<x)
6292 {
6293 56676 return l_up;
6294 }
6295 else
6296 {
6297 49404 return r_up;
6298 }
6299 }
6300 else
6301 {
6302
2/2
✓ Branch 0 taken 76696 times.
✓ Branch 1 taken 71072 times.
147768 if(lx<x)
6303 {
6304 71072 return l_down;
6305 }
6306 else
6307 {
6308 76696 return r_down;
6309 }
6310 }
6311 }
6312 418742 }
6313
6314 578826 return -1;
6315 927949 }
6316
6317 // returns true if Hero is within 'range' pixels of the enemy
6318 27884 bool enemy::HeroInRange(int32_t range)
6319 {
6320 27884 int32_t lx = Hero.getX();
6321 27884 int32_t ly = Hero.getY();
6322
2/2
✓ Branch 0 taken 22775 times.
✓ Branch 1 taken 5109 times.
27884 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
6323 }
6324
6325 // place the enemy in line with Hero (red wizzrobes)
6326 4899 void enemy::place_on_axis(bool floater, bool solid_ok)
6327 {
6328
6/6
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 4312 times.
✓ Branch 2 taken 4355 times.
✓ Branch 3 taken 544 times.
✓ Branch 4 taken 587 times.
✓ Branch 5 taken 3768 times.
4899 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
6329
6/6
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 4460 times.
✓ Branch 2 taken 4109 times.
✓ Branch 3 taken 790 times.
✓ Branch 4 taken 439 times.
✓ Branch 5 taken 3670 times.
4899 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
6330 4899 int32_t pos2=zc_oldrand()%23;
6331 4899 int32_t tried=0;
6332 4899 bool last_resort,placed=false;
6333
6334
6335 4899 do
6336 {
6337
2/2
✓ Branch 0 taken 4460 times.
✓ Branch 1 taken 3127 times.
7587 if(pos2<14)
6338 {
6339 4460 x=(pos2<<4)+16;
6340 4460 y=ly;
6341 4460 }
6342 else
6343 {
6344 3127 x=lx;
6345 3127 y=((pos2-14)<<4)+16;
6346 }
6347
6348 // Don't commit to a last resort if position is out of bounds.
6349
6/6
✓ Branch 0 taken 7248 times.
✓ Branch 1 taken 339 times.
✓ Branch 2 taken 6936 times.
✓ Branch 3 taken 312 times.
✓ Branch 4 taken 257 times.
✓ Branch 5 taken 6679 times.
7587 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
6350
6351
4/4
✓ Branch 0 taken 3907 times.
✓ Branch 1 taken 3680 times.
✓ Branch 2 taken 4862 times.
✓ Branch 3 taken 1287 times.
7587 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
6352 {
6353 // Red Wizzrobes should be able to appear on water, but not other
6354 // solid combos; however, they could appear on solid combos in 2.10,
6355 // and some quests depend on that.
6356
4/4
✓ Branch 0 taken 2341 times.
✓ Branch 1 taken 6201 times.
✓ Branch 2 taken 1302 times.
✓ Branch 3 taken 4899 times.
8542 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
6357 8542 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
6358 4899 placed=true;
6359 8542 }
6360
6361
3/6
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4537 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2688 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7225 if(!placed && tried>=22 && last_resort)
6362 {
6363 placed=true;
6364 }
6365
6366 7225 ++tried;
6367 7225 pos2=(pos2+3)%23;
6368
2/2
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4537 times.
7225 }
6369 7225 while(!placed);
6370
6371
2/2
✓ Branch 0 taken 2729 times.
✓ Branch 1 taken 1808 times.
4537 if(y==ly)
6372 2729 dir=(x<lx)?right:left;
6373 else
6374 1808 dir=(y<ly)?down:up;
6375
6376 4537 clk2=tried;
6377 4537 }
6378
6379 20335203 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
6380 {
6381 20335203 int32_t t = o_tile;
6382 20335203 int32_t b = o_tile;
6383
6384 // Darknuts, but also Wizzrobes and Wallmasters
6385
3/4
✓ Branch 0 taken 8417552 times.
✓ Branch 1 taken 10877881 times.
✓ Branch 2 taken 1039770 times.
✗ Branch 3 not taken.
20335203 switch(type)
6386 {
6387 case eeWALK:
6388
5/6
✓ Branch 0 taken 505407 times.
✓ Branch 1 taken 10372474 times.
✓ Branch 2 taken 367468 times.
✓ Branch 3 taken 137939 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 367468 times.
10877881 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
6389 {
6390 367468 tile=s_tile;
6391 367468 t=s_tile;
6392 367468 b=s_tile;
6393 367468 }
6394
6395 10877881 break;
6396
6397 case eeTRAP:
6398
4/6
✓ Branch 0 taken 193566 times.
✓ Branch 1 taken 846204 times.
✓ Branch 2 taken 193566 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 193566 times.
1039770 if(dummy_int[1] && guysbuf[id].flags & guy_trp2 && do_animation) // Just to make sure
6399 {
6400 193566 tile=s_tile;
6401 193566 t=s_tile;
6402 193566 b=s_tile;
6403 193566 }
6404
6405 1039770 break;
6406
6407 case eeSPINTILE:
6408 if(misc>=96 && do_animation)
6409 {
6410 tile=o_tile+frames*ndir;
6411 t=tile;
6412 }
6413
6414 break;
6415 }
6416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20335203 times.
20335203 if ( do_animation )
6417 {
6418
4/6
✓ Branch 0 taken 197042 times.
✓ Branch 1 taken 20138161 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 267131 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 19871030 times.
20335203 if(ndir!=0) switch(frames)
6419 {
6420 case 2:
6421 267131 tiledir_small(dir,ndir==4);
6422 267131 break;
6423
6424 case 3:
6425 tiledir_three(dir);
6426 break;
6427
6428 case 4:
6429 19871030 tiledir(dir,ndir==4);
6430 19871030 break;
6431 20138161 }
6432
6433
2/2
✓ Branch 0 taken 10877881 times.
✓ Branch 1 taken 9457322 times.
20335203 if(type==eeWALK)
6434
6/6
✓ Branch 0 taken 10816559 times.
✓ Branch 1 taken 61322 times.
✓ Branch 2 taken 8211621 times.
✓ Branch 3 taken 2666260 times.
✓ Branch 4 taken 2650448 times.
✓ Branch 5 taken 15812 times.
10877881 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
6435 else
6436 9457322 tile+=f4;
6437 20335203 }
6438 20335203 return b;
6439 }
6440
6441 void enemy::tiledir_three(int32_t ndir)
6442 {
6443 if ( !do_animation ) return;
6444 flip=0;
6445
6446 switch(ndir)
6447 {
6448 case right:
6449 tile+=3;
6450 [[fallthrough]];
6451
6452 case left:
6453 tile+=3;
6454 [[fallthrough]];
6455
6456 case down:
6457 tile+=3;
6458 [[fallthrough]];
6459
6460 case up:
6461 break;
6462 }
6463 }
6464
6465 267131 void enemy::tiledir_small(int32_t ndir, bool fourdir)
6466 {
6467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267131 times.
267131 if ( !do_animation ) return;
6468 267131 flip=0;
6469
6470
8/9
✓ Branch 0 taken 53829 times.
✓ Branch 1 taken 54679 times.
✓ Branch 2 taken 67727 times.
✓ Branch 3 taken 71182 times.
✓ Branch 4 taken 5706 times.
✓ Branch 5 taken 5154 times.
✓ Branch 6 taken 4872 times.
✓ Branch 7 taken 3982 times.
✗ Branch 8 not taken.
267131 switch(ndir)
6471 {
6472 case 8:
6473 case up:
6474 53829 break;
6475
6476 case 12:
6477 case down:
6478 54679 tile+=2;
6479 54679 break;
6480
6481 case 14:
6482 case left:
6483 67727 tile+=4;
6484 67727 break;
6485
6486 case 10:
6487 case right:
6488 71182 tile+=6;
6489 71182 break;
6490
6491 case 9:
6492 case r_up:
6493
1/2
✓ Branch 0 taken 5706 times.
✗ Branch 1 not taken.
5706 if(fourdir)
6494 5706 break;
6495
6496 tile+=10;
6497 break;
6498
6499 case 11:
6500 case r_down:
6501
1/2
✓ Branch 0 taken 5154 times.
✗ Branch 1 not taken.
5154 if(fourdir)
6502 5154 tile+=2;
6503 else
6504 tile+=14;
6505
6506 5154 break;
6507
6508 case 13:
6509 case l_down:
6510
1/2
✓ Branch 0 taken 4872 times.
✗ Branch 1 not taken.
4872 if(fourdir)
6511 4872 tile+=2;
6512 else
6513 tile+=12;
6514
6515 4872 break;
6516
6517 case 15:
6518 case l_up:
6519
1/2
✓ Branch 0 taken 3982 times.
✗ Branch 1 not taken.
3982 if(fourdir)
6520 3982 break;
6521
6522 tile+=8;
6523 break;
6524
6525 default:
6526 //dir=(zc_oldrand()*100)%8;
6527 //tiledir_small(dir);
6528 // flip=zc_oldrand()&3;
6529 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6530 break;
6531 }
6532 267131 }
6533
6534 23203778 void enemy::tiledir(int32_t ndir, bool fourdir)
6535 {
6536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23203778 times.
23203778 if ( !do_animation ) return;
6537 23203778 flip=0;
6538
6539
9/9
✓ Branch 0 taken 4509460 times.
✓ Branch 1 taken 4163442 times.
✓ Branch 2 taken 5444983 times.
✓ Branch 3 taken 5198041 times.
✓ Branch 4 taken 834140 times.
✓ Branch 5 taken 1027612 times.
✓ Branch 6 taken 1106457 times.
✓ Branch 7 taken 852481 times.
✓ Branch 8 taken 67162 times.
23203778 switch(ndir)
6540 {
6541 case 8:
6542 case up:
6543 4509460 break;
6544
6545 case 12:
6546 case down:
6547 4163442 tile+=4;
6548 4163442 break;
6549
6550 case 14:
6551 case left:
6552 5444983 tile+=8;
6553 5444983 break;
6554
6555 case 10:
6556 case right:
6557 5198041 tile+=12;
6558 5198041 break;
6559
6560 case 9:
6561 case r_up:
6562
2/2
✓ Branch 0 taken 89257 times.
✓ Branch 1 taken 744883 times.
834140 if(fourdir)
6563 89257 break;
6564 else
6565 744883 tile+=24;
6566
6567 744883 break;
6568
6569 case 11:
6570 case r_down:
6571
2/2
✓ Branch 0 taken 102657 times.
✓ Branch 1 taken 924955 times.
1027612 if(fourdir)
6572 102657 tile+=4;
6573 else
6574 924955 tile+=32;
6575
6576 1027612 break;
6577
6578 case 13:
6579 case l_down:
6580
2/2
✓ Branch 0 taken 106171 times.
✓ Branch 1 taken 1000286 times.
1106457 if(fourdir)
6581 106171 tile+=4;
6582 else
6583 1000286 tile+=28;
6584
6585 1106457 break;
6586
6587 case 15:
6588 case l_up:
6589
2/2
✓ Branch 0 taken 82882 times.
✓ Branch 1 taken 769599 times.
852481 if(fourdir)
6590 82882 break;
6591 else
6592 769599 tile+=20;
6593
6594 769599 break;
6595
6596 default:
6597 //dir=(zc_oldrand()*100)%8;
6598 //tiledir(dir);
6599 // flip=zc_oldrand()&3;
6600 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6601 67162 break;
6602 }
6603 23203778 }
6604
6605 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
6606 {
6607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if ( !do_animation ) return;
6608 3868 flip=0;
6609
6610
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
6611 {
6612 case 8:
6613 case up:
6614 297 break;
6615
6616 case 12:
6617 case down:
6618 tile+=8;
6619 break;
6620
6621 case 14:
6622 case left:
6623 195 tile+=40;
6624 195 break;
6625
6626 case 10:
6627 case right:
6628 179 tile+=48;
6629 179 break;
6630
6631 case 9:
6632 case r_up:
6633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
6634 break;
6635
6636 306 tile+=88;
6637 306 break;
6638
6639 case 11:
6640 case r_down:
6641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
6642 tile+=8;
6643 else
6644 1235 tile+=128;
6645
6646 1235 break;
6647
6648 case 13:
6649 case l_down:
6650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
6651 tile+=8;
6652 else
6653 1324 tile+=120;
6654
6655 1324 break;
6656
6657 case 15:
6658 case l_up:
6659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
6660 break;
6661
6662 332 tile+=80;
6663 332 break;
6664
6665 default:
6666 //dir=(zc_oldrand()*100)%8;
6667 //tiledir_big(dir);
6668 // flip=zc_oldrand()&3;
6669 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6670 break;
6671 }
6672 3868 }
6673
6674 40162690 void enemy::update_enemy_frame()
6675 {
6676
4/4
✓ Branch 0 taken 40160315 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 40160308 times.
40162690 if(fallclk||drownclk) return;
6677
1/2
✓ Branch 0 taken 40160308 times.
✗ Branch 1 not taken.
40160308 if (!do_animation)
6678 return;
6679
6680
4/4
✓ Branch 0 taken 1549487 times.
✓ Branch 1 taken 38610821 times.
✓ Branch 2 taken 1547480 times.
✓ Branch 3 taken 2007 times.
40160308 if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
6681
6682
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
40160308 if(get_qr(qr_ANONE_NOANIM)
6683
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 40160308 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
40160308 && anim == aNONE && type != eeGUY)
6684 return;
6685
2/2
✓ Branch 0 taken 371376 times.
✓ Branch 1 taken 39788932 times.
40160308 int32_t newfrate = zc_max(frate,4);
6686 40160308 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
6687 40160308 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
6688
2/2
✓ Branch 0 taken 30164014 times.
✓ Branch 1 taken 9996294 times.
40160308 int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2;
6689 40160308 tile = o_tile;
6690 40160308 int32_t basetile = o_tile;
6691 40160308 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
6692 40160308 bool ignore_extend = false;
6693
35/40
✓ Branch 0 taken 220021 times.
✓ Branch 1 taken 8628 times.
✓ Branch 2 taken 209083 times.
✓ Branch 3 taken 1755010 times.
✓ Branch 4 taken 363745 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140514 times.
✓ Branch 7 taken 366633 times.
✓ Branch 8 taken 836734 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 5096784 times.
✓ Branch 12 taken 69324 times.
✓ Branch 13 taken 53456 times.
✓ Branch 14 taken 38833 times.
✓ Branch 15 taken 455374 times.
✓ Branch 16 taken 1525813 times.
✓ Branch 17 taken 197042 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 128880 times.
✓ Branch 20 taken 221637 times.
✓ Branch 21 taken 693272 times.
✓ Branch 22 taken 1694695 times.
✓ Branch 23 taken 1134909 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 267131 times.
✓ Branch 26 taken 4134724 times.
✓ Branch 27 taken 7515986 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 582937 times.
✓ Branch 30 taken 1178979 times.
✓ Branch 31 taken 880176 times.
✓ Branch 32 taken 219096 times.
✓ Branch 33 taken 1818304 times.
✓ Branch 34 taken 133344 times.
✓ Branch 35 taken 1433 times.
✓ Branch 36 taken 7018408 times.
✓ Branch 37 taken 747030 times.
✓ Branch 38 taken 276997 times.
✓ Branch 39 taken 171508 times.
40160308 switch(anim)
6694 {
6695
6696 case aDONGO:
6697 {
6698 69324 int32_t fr = stunclk>0 ? 16 : 8;
6699
6700
6/6
✓ Branch 0 taken 67426 times.
✓ Branch 1 taken 1898 times.
✓ Branch 2 taken 6720 times.
✓ Branch 3 taken 60706 times.
✓ Branch 4 taken 2240 times.
✓ Branch 5 taken 4480 times.
69324 if(!dying && clk2>0 && clk2<=64)
6701 {
6702 // bloated
6703
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 960 times.
✓ Branch 3 taken 1664 times.
✓ Branch 4 taken 896 times.
4480 switch(dir)
6704 {
6705 case up:
6706 960 tile+=9;
6707 960 flip=0;
6708 960 xofs=0;
6709 960 dummy_int[1]=0; //no additional tiles
6710 960 break;
6711
6712 case down:
6713 960 tile+=7;
6714 960 flip=0;
6715 960 xofs=0;
6716 960 dummy_int[1]=0; //no additional tiles
6717 960 break;
6718
6719 case left:
6720 1664 flip=1;
6721 1664 tile+=4;
6722 1664 xofs=16;
6723 1664 dummy_int[1]=1; //second tile is next tile
6724 1664 break;
6725
6726 case right:
6727 896 flip=0;
6728 896 tile+=5;
6729 896 xofs=16;
6730 896 dummy_int[1]=-1; //second tile is previous tile
6731 896 break;
6732 }
6733 4480 }
6734
4/4
✓ Branch 0 taken 1898 times.
✓ Branch 1 taken 62946 times.
✓ Branch 2 taken 781 times.
✓ Branch 3 taken 1117 times.
64844 else if(!dying || clk2>19)
6735 {
6736 // normal
6737
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 13652 times.
✓ Branch 2 taken 15374 times.
✓ Branch 3 taken 19615 times.
✓ Branch 4 taken 15086 times.
63727 switch(dir)
6738 {
6739 case up:
6740 13652 tile+=8;
6741 13652 flip=(clk&fr)?1:0;
6742 13652 xofs=0;
6743 13652 dummy_int[1]=0; //no additional tiles
6744 13652 break;
6745
6746 case down:
6747 15374 tile+=6;
6748 15374 flip=(clk&fr)?1:0;
6749 15374 xofs=0;
6750 15374 dummy_int[1]=0; //no additional tiles
6751 15374 break;
6752
6753 case left:
6754 19615 flip=1;
6755 19615 tile+=(clk&fr)?2:0;
6756 19615 xofs=16;
6757 19615 dummy_int[1]=1; //second tile is next tile
6758 19615 break;
6759
6760 case right:
6761 15086 flip=0;
6762 15086 tile+=(clk&fr)?3:1;
6763 15086 xofs=16;
6764 15086 dummy_int[1]=-1; //second tile is next tile
6765 15086 break;
6766 }
6767 63727 }
6768 }
6769 69324 break;
6770
6771 case aNEWDONGO:
6772 {
6773 53456 int32_t fr4=0;
6774
6775
6/6
✓ Branch 0 taken 51564 times.
✓ Branch 1 taken 1892 times.
✓ Branch 2 taken 4128 times.
✓ Branch 3 taken 47436 times.
✓ Branch 4 taken 1376 times.
✓ Branch 5 taken 2752 times.
53456 if(!dying && clk2>0 && clk2<=64)
6776 {
6777 // bloated
6778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2752 times.
2752 if(clk2>=0)
6779 {
6780 2752 fr4=3;
6781 2752 }
6782
6783
2/2
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 2107 times.
2752 if(clk2>=16)
6784 {
6785 2107 fr4=2;
6786 2107 }
6787
6788
2/2
✓ Branch 0 taken 1333 times.
✓ Branch 1 taken 1419 times.
2752 if(clk2>=32)
6789 {
6790 1419 fr4=1;
6791 1419 }
6792
6793
2/2
✓ Branch 0 taken 2021 times.
✓ Branch 1 taken 731 times.
2752 if(clk2>=48)
6794 {
6795 731 fr4=0;
6796 731 }
6797
6798
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 704 times.
✓ Branch 4 taken 1216 times.
2752 switch(dir)
6799 {
6800 case up:
6801 256 xofs=0;
6802 256 tile+=8+fr4;
6803 256 dummy_int[1]=0; //no additional tiles
6804 256 break;
6805
6806 case down:
6807 576 xofs=0;
6808 576 tile+=12+fr4;
6809 576 dummy_int[1]=0; //no additional tiles
6810 576 break;
6811
6812 case left:
6813 704 tile+=29+(2*fr4);
6814 704 xofs=16;
6815 704 dummy_int[1]=-1; //second tile is previous tile
6816 704 break;
6817
6818 case right:
6819 1216 tile+=49+(2*fr4);
6820 1216 xofs=16;
6821 1216 dummy_int[1]=-1; //second tile is previous tile
6822 1216 break;
6823 }
6824 2752 }
6825
4/4
✓ Branch 0 taken 1892 times.
✓ Branch 1 taken 48812 times.
✓ Branch 2 taken 994 times.
✓ Branch 3 taken 898 times.
50704 else if(!dying || clk2>19)
6826 {
6827 // normal
6828
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9234 times.
✓ Branch 2 taken 9871 times.
✓ Branch 3 taken 15025 times.
✓ Branch 4 taken 15676 times.
49806 switch(dir)
6829 {
6830 case up:
6831 9234 xofs=0;
6832 9234 tile+=((clk&12)>>2);
6833 9234 dummy_int[1]=0; //no additional tiles
6834 9234 break;
6835
6836 case down:
6837 9871 xofs=0;
6838 9871 tile+=4+((clk&12)>>2);
6839 9871 dummy_int[1]=0; //no additional tiles
6840 9871 break;
6841
6842 case left:
6843 15025 tile+=21+((clk&12)>>1);
6844 15025 xofs=16;
6845 15025 dummy_int[1]=-1; //second tile is previous tile
6846 15025 break;
6847
6848 case right:
6849 15676 flip=0;
6850 15676 tile+=41+((clk&12)>>1);
6851 15676 xofs=16;
6852 15676 dummy_int[1]=-1; //second tile is previous tile
6853 15676 break;
6854 }
6855 49806 }
6856 }
6857 53456 break;
6858
6859 case aDONGOBS:
6860 {
6861 38833 int32_t fr4=0;
6862
6863
6/6
✓ Branch 0 taken 37675 times.
✓ Branch 1 taken 1158 times.
✓ Branch 2 taken 4032 times.
✓ Branch 3 taken 33643 times.
✓ Branch 4 taken 1344 times.
✓ Branch 5 taken 2688 times.
38833 if(!dying && clk2>0 && clk2<=64)
6864 {
6865 // bloated
6866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2688 times.
2688 if(clk2>=0)
6867 {
6868 2688 fr4=3;
6869 2688 }
6870
6871
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 2058 times.
2688 if(clk2>=16)
6872 {
6873 2058 fr4=2;
6874 2058 }
6875
6876
2/2
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 1386 times.
2688 if(clk2>=32)
6877 {
6878 1386 fr4=1;
6879 1386 }
6880
6881
2/2
✓ Branch 0 taken 1974 times.
✓ Branch 1 taken 714 times.
2688 if(clk2>=48)
6882 {
6883 714 fr4=0;
6884 714 }
6885
6886
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 384 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1024 times.
2688 switch(dir)
6887 {
6888 case up:
6889 256 tile+=28+fr4;
6890 256 yofs+=8;
6891 256 dummy_int[1]=-20; //second tile change
6892 256 dummy_int[2]=0; //new xofs change
6893 256 dummy_int[3]=-16; //new xofs change
6894 256 break;
6895
6896 case down:
6897 384 tile+=12+fr4;
6898 384 yofs-=8;
6899 384 dummy_int[1]=20; //second tile change
6900 384 dummy_int[2]=0; //new xofs change
6901 384 dummy_int[3]=16; //new xofs change
6902 384 break;
6903
6904 case left:
6905 1024 tile+=49+(2*fr4);
6906 1024 xofs+=8;
6907 1024 dummy_int[1]=-1; //second tile change
6908 1024 dummy_int[2]=-16; //new xofs change
6909 1024 dummy_int[3]=0; //new xofs change
6910 1024 break;
6911
6912 case right:
6913 1024 tile+=69+(2*fr4);
6914 1024 xofs+=8;
6915 1024 dummy_int[1]=-1; //second tile change
6916 1024 dummy_int[2]=-16; //new xofs change
6917 1024 dummy_int[3]=0; //new xofs change
6918 1024 break;
6919 }
6920 2688 }
6921
4/4
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 34987 times.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 661 times.
36145 else if(!dying || clk2>19)
6922 {
6923 // normal
6924
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7136 times.
✓ Branch 2 taken 6672 times.
✓ Branch 3 taken 11075 times.
✓ Branch 4 taken 10601 times.
35484 switch(dir)
6925 {
6926 case up:
6927 7136 tile+=20+((clk&24)>>3);
6928 7136 yofs+=8;
6929 7136 dummy_int[1]=-20; //second tile change
6930 7136 dummy_int[2]=0; //new xofs change
6931 7136 dummy_int[3]=-16; //new xofs change
6932 7136 break;
6933
6934 case down:
6935 6672 tile+=4+((clk&24)>>3);
6936 6672 yofs-=8;
6937 6672 dummy_int[1]=20; //second tile change
6938 6672 dummy_int[2]=0; //new xofs change
6939 6672 dummy_int[3]=16; //new xofs change
6940 6672 break;
6941
6942 case left:
6943 11075 xofs=-8;
6944 11075 tile+=40+((clk&24)>>2);
6945 11075 dummy_int[1]=1; //second tile change
6946 11075 dummy_int[2]=16; //new xofs change
6947 11075 dummy_int[3]=0; //new xofs change
6948 11075 break;
6949
6950 case right:
6951 10601 tile+=60+((clk&24)>>2);
6952 10601 xofs=-8;
6953 10601 dummy_int[1]=1; //second tile change
6954 10601 dummy_int[2]=16; //new xofs change
6955 10601 dummy_int[3]=0; //new xofs change
6956 10601 break;
6957 }
6958 35484 }
6959 }
6960 38833 break;
6961
6962 case aWIZZ:
6963 {
6964 // if(d->misc1)
6965
2/2
✓ Branch 0 taken 182184 times.
✓ Branch 1 taken 273190 times.
455374 if(dmisc1)
6966 {
6967
2/2
✓ Branch 0 taken 91057 times.
✓ Branch 1 taken 91127 times.
182184 if(clk&8)
6968 {
6969 91127 ++tile;
6970 91127 }
6971 182184 }
6972 else
6973 {
6974
2/2
✓ Branch 0 taken 136701 times.
✓ Branch 1 taken 136489 times.
273190 if(frame&4)
6975 {
6976 136489 ++tile;
6977 136489 }
6978 }
6979
6980
4/4
✓ Branch 0 taken 76094 times.
✓ Branch 1 taken 157108 times.
✓ Branch 2 taken 145581 times.
✓ Branch 3 taken 76591 times.
455374 switch(dir)
6981 {
6982 case 9:
6983 case 15:
6984 case up:
6985 76094 tile+=2;
6986 76094 break;
6987
6988 case down:
6989 76591 break;
6990
6991 case 13:
6992 case left:
6993 157108 flip=1;
6994 157108 break;
6995
6996 default:
6997 145581 flip=0;
6998 145581 break;
6999 }
7000 }
7001 455374 break;
7002
7003 case aNEWWIZZ:
7004 {
7005 1525813 tiledir(dir,true);
7006
7007 // if(d->misc1) //walking wizzrobe
7008
2/2
✓ Branch 0 taken 742424 times.
✓ Branch 1 taken 783389 times.
1525813 if(dmisc1) //walking wizzrobe
7009 {
7010
2/2
✓ Branch 0 taken 373321 times.
✓ Branch 1 taken 369103 times.
742424 if(clk&8)
7011 {
7012 369103 tile+=2;
7013 369103 }
7014
7015
2/2
✓ Branch 0 taken 372085 times.
✓ Branch 1 taken 370339 times.
742424 if(clk&4)
7016 {
7017 370339 tile+=1;
7018 370339 }
7019
7020
2/4
✓ Branch 0 taken 742424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 742424 times.
742424 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
7021 {
7022
2/2
✓ Branch 0 taken 663262 times.
✓ Branch 1 taken 79162 times.
742424 if(dummy_int[1]>0)
7023 {
7024 79162 tile+=40;
7025 79162 }
7026 742424 }
7027 742424 }
7028 else
7029 {
7030
4/4
✓ Branch 0 taken 716244 times.
✓ Branch 1 taken 67145 times.
✓ Branch 2 taken 168827 times.
✓ Branch 3 taken 547417 times.
783389 if(dummy_bool[1]||dummy_bool[2])
7031 {
7032 235972 tile+=20;
7033
7034
2/2
✓ Branch 0 taken 67136 times.
✓ Branch 1 taken 168836 times.
235972 if(dummy_bool[2])
7035 {
7036 168836 tile+=20;
7037 168836 }
7038 235972 }
7039
7040 783389 tile+=((frame>>1)&3);
7041 }
7042 }
7043 1525813 break;
7044
7045 case a3FRM:
7046 {
7047
2/2
✓ Branch 0 taken 46675 times.
✓ Branch 1 taken 150367 times.
197042 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
7048 }
7049 197042 break;
7050
7051 case a3FRM4DIR:
7052 {
7053 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
7054 }
7055 break;
7056
7057 case aVIRE:
7058 {
7059
2/2
✓ Branch 0 taken 99588 times.
✓ Branch 1 taken 29292 times.
128880 if(dir==up)
7060 {
7061 29292 tile+=2;
7062 29292 }
7063
7064 128880 tile+=fx;
7065 }
7066 128880 break;
7067
7068 case aROPE:
7069 {
7070 220021 tile+=(1-fx);
7071 220021 flip = dir==left ? 1:0;
7072 }
7073 220021 break;
7074
7075 case aZORA:
7076 {
7077 int32_t dl;
7078
7079
2/2
✓ Branch 0 taken 46739 times.
✓ Branch 1 taken 174898 times.
221637 if(clk<36)
7080 {
7081 46739 dl=clk+5;
7082 46739 goto waves2;
7083 }
7084
7085
2/2
✓ Branch 0 taken 82440 times.
✓ Branch 1 taken 92458 times.
174898 if(clk<36+66)
7086
2/2
✓ Branch 0 taken 50715 times.
✓ Branch 1 taken 31725 times.
82440 tile=(dir==up)?o_tile+1:o_tile;
7087 else
7088 {
7089 92458 dl=clk-36-66;
7090 waves2:
7091 139197 tile=((dl/11)&1)+s_tile;
7092 139197 basetile = s_tile;
7093 }
7094 }
7095 221637 break;
7096
7097 case aNEWZORA:
7098 {
7099 693272 f4=(clk/16)%4;
7100
7101 693272 tiledir(dir,true);
7102 int32_t dl;
7103
7104
4/4
✓ Branch 0 taken 489980 times.
✓ Branch 1 taken 203292 times.
✓ Branch 2 taken 251304 times.
✓ Branch 3 taken 238676 times.
693272 if((clk>35)&&(clk<36+67)) //surfaced
7105 {
7106
4/4
✓ Branch 0 taken 204043 times.
✓ Branch 1 taken 34633 times.
✓ Branch 2 taken 29458 times.
✓ Branch 3 taken 174585 times.
238676 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
7107 {
7108 174585 tile+=80;
7109 174585 } //mouth closed
7110 else
7111 {
7112 64091 tile+=40;
7113 }
7114
7115 238676 tile+=f4;
7116 238676 }
7117 else
7118 {
7119
2/2
✓ Branch 0 taken 203292 times.
✓ Branch 1 taken 251304 times.
454596 if(clk<36)
7120 {
7121 203292 dl=clk+5;
7122 203292 }
7123 else
7124 {
7125 251304 dl=clk-36-66;
7126 }
7127
7128 454596 tile+=((dl/5)&3);
7129 }
7130 }
7131 693272 break;
7132
7133 case a4FRM4EYE:
7134 case a2FRM4EYE:
7135 case a4FRM8EYE:
7136 case a4FRM8EYEB: //big version
7137 case a4FRM4EYEB:
7138 {
7139 836734 tilerows = 2;
7140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakex = x + 8*(zc_max(1,txsz)-1);
7141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakey = y + 8*(zc_max(1,tysz)-1);
7142 double _MSVC2022_tmp1, _MSVC2022_tmp2;
7143 836734 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
7144 836734 int32_t lookat=zc_oldrand()&15;
7145
7146
4/4
✓ Branch 0 taken 272091 times.
✓ Branch 1 taken 564643 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 210774 times.
836734 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
7147 {
7148 210774 lookat=l_down;
7149 210774 }
7150
4/4
✓ Branch 0 taken 288167 times.
✓ Branch 1 taken 337793 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 226850 times.
625960 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
7151 {
7152 226850 lookat=down;
7153 226850 }
7154
4/4
✓ Branch 0 taken 170154 times.
✓ Branch 1 taken 228956 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 108837 times.
399110 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
7155 {
7156 108837 lookat=r_down;
7157 108837 }
7158
4/4
✓ Branch 0 taken 131712 times.
✓ Branch 1 taken 158561 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 70395 times.
290273 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
7159 {
7160 70395 lookat=right;
7161 70395 }
7162
4/4
✓ Branch 0 taken 96384 times.
✓ Branch 1 taken 123494 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 35067 times.
219878 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
7163 {
7164 35067 lookat=r_up;
7165 35067 }
7166
4/4
✓ Branch 0 taken 86753 times.
✓ Branch 1 taken 98058 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 25436 times.
184811 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
7167 {
7168 25436 lookat=up;
7169 25436 }
7170
4/4
✓ Branch 0 taken 98120 times.
✓ Branch 1 taken 61255 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 36803 times.
159375 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
7171 {
7172 36803 lookat=l_up;
7173 36803 }
7174 else
7175 {
7176 122572 lookat=left;
7177 }
7178
7179 836734 int32_t dir2 = dir;
7180 836734 dir = lookat;
7181
3/6
✓ Branch 0 taken 836734 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 836734 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 836734 times.
836734 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
7182 else
7183 {
7184 tiledir_big(dir,(anim == a4FRM4EYEB));
7185 tile+=2*f4;
7186 ignore_extend = true;
7187 }
7188 836734 dir = dir2;
7189 }
7190 836734 break;
7191
7192 case aFLIP:
7193 {
7194 1694695 flip = f2&1;
7195 }
7196 1694695 break;
7197
7198 case a2FRM:
7199 {
7200 1134909 tile += (1-f2);
7201 }
7202 1134909 break;
7203
7204 case a2FRMB:
7205 {
7206 tile+= 2*(1-f2);
7207 ignore_extend = true;
7208 }
7209 break;
7210
7211 case a2FRM4DIR:
7212 {
7213 267131 basetile = n_frame_n_dir(2, 4, f2&1);
7214 }
7215 267131 break;
7216
7217 case a4FRM4DIRF:
7218 {
7219 4134724 basetile = n_frame_n_dir(4,4,f4);
7220
7221
2/2
✓ Branch 0 taken 2733716 times.
✓ Branch 1 taken 1401008 times.
4134724 if(clk2>0) //stopped to fire
7222 {
7223 1401008 tile+=20;
7224
7225
2/2
✓ Branch 0 taken 698282 times.
✓ Branch 1 taken 702726 times.
1401008 if(clk2<17) //firing
7226 {
7227 702726 tile+=20;
7228 702726 }
7229 1401008 }
7230 }
7231 4134724 break;
7232
7233 case a4FRM4DIR:
7234 {
7235 7515986 basetile = n_frame_n_dir(4,4,f4);
7236 }
7237 7515986 break;
7238
7239 case a4FRM8DIRF:
7240 {
7241 tilerows = 2;
7242 basetile = n_frame_n_dir(4,8,f4);
7243
7244 if(clk2>0) //stopped to fire
7245 {
7246 tile+=40;
7247
7248 if(clk2<17) //firing
7249 {
7250 tile+=40;
7251 }
7252 }
7253 }
7254 break;
7255
7256 case a4FRM8DIRB:
7257 case a4FRM8DIRFB:
7258 {
7259 3868 tilerows = 2;
7260 3868 tiledir_big(dir,false);
7261 3868 tile+=2*f4;
7262
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
7263 {
7264 tile+=80;
7265
7266 if(clk2<17) //firing
7267 {
7268 tile+=80;
7269 }
7270 }
7271 3868 ignore_extend = true;
7272 }
7273 3868 break;
7274
7275 case a4FRM4DIRB:
7276 case a4FRM4DIRFB:
7277 {
7278 tilerows = 2;
7279 tiledir_big(dir,true);
7280 tile+=2*f4;
7281 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
7282 {
7283 tile+=40;
7284
7285 if(clk2<17) //firing
7286 {
7287 tile+=40;
7288 }
7289 }
7290 ignore_extend = true;
7291 }
7292 break;
7293
7294 case aOCTO:
7295 {
7296
5/5
✓ Branch 0 taken 4152 times.
✓ Branch 1 taken 122459 times.
✓ Branch 2 taken 133448 times.
✓ Branch 3 taken 165651 times.
✓ Branch 4 taken 157227 times.
582937 switch(dir)
7297 {
7298 case up:
7299 122459 flip = 2;
7300 122459 break;
7301
7302 case down:
7303 133448 flip = 0;
7304 133448 break;
7305
7306 case left:
7307 165651 flip = 0;
7308 165651 tile += 2;
7309 165651 break;
7310
7311 case right:
7312 157227 flip = 1;
7313 157227 tile += 2;
7314 157227 break;
7315 }
7316
7317 582937 tile+=f2;
7318 }
7319 582937 break;
7320
7321 case aWALK:
7322 {
7323
5/5
✓ Branch 0 taken 5614 times.
✓ Branch 1 taken 248704 times.
✓ Branch 2 taken 267165 times.
✓ Branch 3 taken 331694 times.
✓ Branch 4 taken 325802 times.
1178979 switch(dir)
7324 {
7325 case up:
7326 248704 tile+=3;
7327 248704 flip = f2;
7328 248704 break;
7329
7330 case down:
7331 267165 tile+=2;
7332 267165 flip = f2;
7333 267165 break;
7334
7335 case left:
7336 331694 flip=1;
7337 331694 tile += f2;
7338 331694 break;
7339
7340 case right:
7341 325802 flip=0;
7342 325802 tile += f2;
7343 325802 break;
7344 }
7345 }
7346 1178979 break;
7347
7348 case aDWALK:
7349 {
7350
3/4
✓ Branch 0 taken 92330 times.
✓ Branch 1 taken 787846 times.
✓ Branch 2 taken 92330 times.
✗ Branch 3 not taken.
880176 if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
7351 {
7352 tile=s_tile;
7353 basetile = s_tile;
7354 }
7355
7356
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 177728 times.
✓ Branch 2 taken 185581 times.
✓ Branch 3 taken 260885 times.
✓ Branch 4 taken 255982 times.
880176 switch(dir)
7357 {
7358 case up:
7359 177728 tile+=2;
7360 177728 flip=f2;
7361 177728 break;
7362
7363 case down:
7364 185581 flip=0;
7365 185581 tile+=(1-f2);
7366 185581 break;
7367
7368 case left:
7369 260885 flip=1;
7370 260885 tile+=(3+f2);
7371 260885 break;
7372
7373 case right:
7374 255982 flip=0;
7375 255982 tile+=(3+f2);
7376 255982 break;
7377 }
7378 }
7379 880176 break;
7380
7381 case aTEK:
7382 {
7383
2/2
✓ Branch 0 taken 139976 times.
✓ Branch 1 taken 79120 times.
219096 if(misc==0)
7384 {
7385 79120 tile += f2;
7386 79120 }
7387
2/2
✓ Branch 0 taken 73149 times.
✓ Branch 1 taken 66827 times.
139976 else if(misc!=1)
7388 {
7389 66827 ++tile;
7390 66827 }
7391 }
7392 219096 break;
7393
7394 case aNEWTEK:
7395 {
7396
2/2
✓ Branch 0 taken 475246 times.
✓ Branch 1 taken 1343058 times.
1818304 if(step<0) //up
7397 {
7398
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 235369 times.
✓ Branch 2 taken 239877 times.
475246 switch(clk3)
7399 {
7400 case left:
7401 235369 flip=0;
7402 235369 tile+=20;
7403 235369 break;
7404
7405 case right:
7406 239877 flip=0;
7407 239877 tile+=24;
7408 239877 break;
7409 }
7410 475246 }
7411
2/2
✓ Branch 0 taken 54749 times.
✓ Branch 1 taken 1288309 times.
1343058 else if(step==0)
7412 {
7413
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 40566 times.
✓ Branch 2 taken 14183 times.
54749 switch(clk3)
7414 {
7415 case left:
7416 40566 flip=0;
7417 40566 tile+=8;
7418 40566 break;
7419
7420 case right:
7421 14183 flip=0;
7422 14183 tile+=12;
7423 14183 break;
7424 }
7425 54749 } //down
7426 else
7427 {
7428
3/3
✓ Branch 0 taken 109149 times.
✓ Branch 1 taken 593340 times.
✓ Branch 2 taken 585820 times.
1288309 switch(clk3)
7429 {
7430 case left:
7431 593340 flip=0;
7432 593340 tile+=28;
7433 593340 break;
7434
7435 case right:
7436 585820 flip=0;
7437 585820 tile+=32;
7438 585820 break;
7439 }
7440 }
7441
7442
2/2
✓ Branch 0 taken 1238755 times.
✓ Branch 1 taken 579549 times.
1818304 if(misc==0)
7443 {
7444 579549 tile+=f4;
7445 579549 }
7446
2/2
✓ Branch 0 taken 582085 times.
✓ Branch 1 taken 656670 times.
1238755 else if(misc!=1)
7447 {
7448 656670 tile+=2;
7449 656670 }
7450 }
7451 1818304 break;
7452
7453 case aARMOS:
7454 {
7455
2/2
✓ Branch 0 taken 3227 times.
✓ Branch 1 taken 5401 times.
8628 if(!fading)
7456 {
7457 5401 tile += fx;
7458
7459
2/2
✓ Branch 0 taken 4204 times.
✓ Branch 1 taken 1197 times.
5401 if(dir==up)
7460 1197 tile += 2;
7461 5401 }
7462 }
7463 8628 break;
7464
7465 case aARMOS4:
7466 {
7467
5/5
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 29165 times.
✓ Branch 2 taken 92624 times.
✓ Branch 3 taken 43654 times.
✓ Branch 4 taken 43190 times.
209083 switch(dir)
7468 {
7469 case up:
7470 29165 flip=0;
7471 29165 break;
7472
7473 case down:
7474 92624 flip=0;
7475 92624 tile+=4;
7476 92624 break;
7477
7478 case left:
7479 43654 flip=0;
7480 43654 tile+=8;
7481 43654 break;
7482
7483 case right:
7484 43190 flip=0;
7485 43190 tile+=12;
7486 43190 break;
7487 }
7488
7489
2/2
✓ Branch 0 taken 63155 times.
✓ Branch 1 taken 145928 times.
209083 if(!fading)
7490 {
7491 145928 tile+=f4;
7492 145928 }
7493 }
7494 209083 break;
7495
7496 case aGHINI:
7497 {
7498
4/4
✓ Branch 0 taken 28037 times.
✓ Branch 1 taken 32092 times.
✓ Branch 2 taken 72763 times.
✓ Branch 3 taken 452 times.
133344 switch(dir)
7499 {
7500 case 8:
7501 case 9:
7502 case up:
7503 28037 ++tile;
7504 28037 flip=0;
7505 28037 break;
7506
7507 case 15:
7508 452 ++tile;
7509 452 flip=1;
7510 452 break;
7511
7512 case 10:
7513 case 11:
7514 case right:
7515 32092 flip=1;
7516 32092 break;
7517
7518 default:
7519 72763 flip=0;
7520 72763 break;
7521 }
7522 }
7523 133344 break;
7524
7525 case a2FRMPOS:
7526 {
7527 1755010 tile+=posframe;
7528 }
7529 1755010 break;
7530
7531 case a4FRMPOS4DIR:
7532 {
7533 363745 basetile = n_frame_n_dir(4,4,0);
7534 // tile+=f2;
7535 363745 tile+=posframe;
7536 }
7537 363745 break;
7538
7539 case a4FRMPOS4DIRF:
7540 {
7541 1433 basetile = n_frame_n_dir(4,4,0);
7542
7543
2/2
✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 197 times.
1433 if(clk2>0) //stopped to fire
7544 {
7545 197 tile+=20;
7546
7547
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 64 times.
197 if(clk2<17) //firing
7548 {
7549 64 tile+=20;
7550 64 }
7551 197 }
7552
7553 // tile+=f2;
7554 1433 tile+=posframe;
7555 }
7556 1433 break;
7557
7558 case a4FRMPOS8DIR:
7559 {
7560 7018408 tilerows = 2;
7561 7018408 int32_t n = tile;
7562 7018408 basetile = n_frame_n_dir(4,8,0);
7563 // tile+=f2;
7564 7018408 tile+=posframe;
7565 }
7566 7018408 break;
7567
7568 case a4FRMPOS8DIRF:
7569 {
7570 tilerows = 2;
7571 basetile = n_frame_n_dir(4,8,0);
7572
7573 if(clk2>0) //stopped to fire
7574 {
7575 tile+=40;
7576
7577 if(clk2<17) //firing
7578 {
7579 tile+=40;
7580 }
7581 }
7582
7583 tile+=posframe;
7584 }
7585 break;
7586
7587 case aNEWLEV:
7588 {
7589 747030 tiledir(dir,true);
7590
7591
4/5
✓ Branch 0 taken 258994 times.
✓ Branch 1 taken 115368 times.
✓ Branch 2 taken 48980 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 323688 times.
747030 switch(misc)
7592 {
7593 case -1:
7594 case 0:
7595 258994 return;
7596
7597 case 1:
7598
7599 // case 5: cs = d->misc2; break;
7600 case 5:
7601 115368 cs = dmisc2;
7602 115368 break;
7603
7604 case 2:
7605 case 4:
7606 48980 tile += 20;
7607 48980 break;
7608
7609 case 3:
7610 323688 tile += 40;
7611 323688 break;
7612 }
7613
7614 488036 tile+=f4;
7615 }
7616 488036 break;
7617
7618 case aLEV:
7619 {
7620 276997 f4 = ((clk/5)&1);
7621
7622
4/5
✓ Branch 0 taken 127945 times.
✓ Branch 1 taken 33336 times.
✓ Branch 2 taken 14658 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101058 times.
276997 switch(misc)
7623 {
7624 case -1:
7625 case 0:
7626 127945 return;
7627
7628 case 1:
7629
7630 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
7631 case 5:
7632 33336 tile += (f2) ? 1 : 0;
7633 33336 cs = dmisc2;
7634 33336 break;
7635
7636 case 2:
7637 case 4:
7638 14658 tile += 2;
7639 14658 break;
7640
7641 case 3:
7642 101058 tile += (f4) ? 4 : 3;
7643 101058 break;
7644 }
7645 }
7646 149052 break;
7647
7648 case aWALLM:
7649 {
7650
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 139764 times.
140514 if(!dummy_bool[1])
7651 {
7652 139764 tile += f2;
7653 139764 }
7654 }
7655 140514 break;
7656
7657 case aNEWWALLM:
7658 {
7659 366633 int32_t tempdir=0;
7660
7661
4/4
✓ Branch 0 taken 38855 times.
✓ Branch 1 taken 43340 times.
✓ Branch 2 taken 8438 times.
✓ Branch 3 taken 276000 times.
366633 switch(misc)
7662 {
7663 case 1:
7664 case 2:
7665 43340 tempdir=clk3;
7666 43340 break;
7667
7668 case 3:
7669 case 4:
7670 case 5:
7671 38855 tempdir=dir;
7672 38855 break;
7673
7674 case 6:
7675 case 7:
7676 8438 tempdir=clk3^1;
7677 8438 break;
7678 }
7679
7680 366633 tiledir(tempdir,true);
7681
7682
2/2
✓ Branch 0 taken 1908 times.
✓ Branch 1 taken 364725 times.
366633 if(!dummy_bool[1])
7683 {
7684 364725 tile+=f4;
7685 364725 }
7686 }
7687 366633 break;
7688
7689 case a4FRMNODIR:
7690 {
7691 171508 tile+=f4;
7692 }
7693 171508 break;
7694
7695 } // switch(d->anim)
7696
7697 // flashing
7698 // if(d->flags & guy_flashing)
7699
2/2
✓ Branch 0 taken 39025820 times.
✓ Branch 1 taken 747549 times.
39773369 if(flags & guy_flashing)
7700 {
7701 747549 cs = (frame&3) + 6;
7702 747549 }
7703
7704
2/2
✓ Branch 0 taken 39362421 times.
✓ Branch 1 taken 410948 times.
39773369 if(flags&guy_transparent)
7705 {
7706 410948 drawstyle=1;
7707 410948 }
7708
7709 39773369 int32_t change = tile-basetile;
7710
7711
3/6
✓ Branch 0 taken 2054943 times.
✓ Branch 1 taken 37718426 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2054943 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
39773369 if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION)))
7712 {
7713
2/2
✓ Branch 0 taken 1792915 times.
✓ Branch 1 taken 262028 times.
2054943 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
7714 {
7715 1792915 tile=basetile+txsz*change;
7716 1792915 }
7717 else
7718 {
7719 262028 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
7720 }
7721 2054943 }
7722 else
7723 {
7724 37718426 tile=basetile+change;
7725 }
7726 40162690 }
7727
7728 81117 int32_t enemy::wpnsfx(int32_t wpn)
7729 {
7730
3/3
✓ Branch 0 taken 22419 times.
✓ Branch 1 taken 40991 times.
✓ Branch 2 taken 17707 times.
81117 switch (wpn)
7731 {
7732 case wScript1:
7733 case wScript2:
7734 case wScript3:
7735 case wScript4:
7736 case wScript5:
7737 case wScript6:
7738 case wScript7:
7739 case wScript8:
7740 case wScript9:
7741 case wScript10: //sure why not
7742 case ewFireTrail:
7743 case ewFlame:
7744 case ewFlame2Trail:
7745 case ewFlame2:
7746 case ewWind:
7747 case ewMagic:
7748 case ewIce:
7749 22419 return firesfx;
7750
7751 case ewRock:
7752 case ewFireball2:
7753 case ewFireball:
7754
2/2
✓ Branch 0 taken 5533 times.
✓ Branch 1 taken 35458 times.
40991 if (get_qr(qr_MORESOUNDS)) return firesfx;
7755 35458 break;
7756 }
7757
7758 53165 return 0;
7759 81117 }
7760
7761 77044177 int32_t enemy::run_script(int32_t mode)
7762 {
7763 void push_ri();
7764 void pop_ri();
7765
7766
3/4
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 77043921 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
77044177 if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
7767
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 77043921 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
77043921 if (script <= 0 || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
7768 77043921 return RUNSCRIPT_OK;
7769 auto scrty = *get_scrtype();
7770 auto uid = getUID();
7771 if(!FFCore.doscript(scrty,uid))
7772 return RUNSCRIPT_OK;
7773 int32_t ret = RUNSCRIPT_OK;
7774 bool& waitdraw = FFCore.waitdraw(scrty, uid);
7775 push_ri();
7776 switch(mode)
7777 {
7778 case MODE_NORMAL:
7779 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7780 break;
7781
7782 case MODE_WAITDRAW:
7783 if(waitdraw)
7784 {
7785 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7786 waitdraw = false;
7787 }
7788 break;
7789 }
7790 pop_ri();
7791 return ret;
7792 77044177 }
7793 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
7794 {
7795 return al_map_rgba(255,0,0,opacity);
7796 }
7797
7798 // good guys, fires, fairy, and other non-enemies
7799 // based on enemy class b/c guys in dungeons act sort of like enemies
7800 // also easier to manage all the guys this way
7801 2191 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
7802 2191 {
7803 2191 mainguy=mg;
7804 2191 canfreeze=false;
7805 2191 dir=down;
7806
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2191 times.
✓ Branch 2 taken 2191 times.
✗ Branch 3 not taken.
2191 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
7807 2191 hxofs=2;
7808 2191 hzsz=8;
7809 2191 hit_width=12;
7810 2191 hit_height=17;
7811
7812
10/12
✓ Branch 0 taken 2191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2191 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 765 times.
✓ Branch 5 taken 1426 times.
✓ Branch 6 taken 743 times.
✓ Branch 7 taken 22 times.
✓ Branch 8 taken 276 times.
✓ Branch 9 taken 467 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 260 times.
2191 if(!superman && (!isdungeon(screen_spawned) || id==gFAIRY || id==gFIRE || id==gZELDA))
7813 {
7814 1931 superman = 1;
7815 1931 hxofs=1000;
7816 1931 }
7817 2191 }
7818
7819 943762 bool guy::animate(int32_t index)
7820 {
7821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 943762 times.
943762 if(switch_hooked) return enemy::animate(index);
7822
6/6
✓ Branch 0 taken 543192 times.
✓ Branch 1 taken 400570 times.
✓ Branch 2 taken 8298 times.
✓ Branch 3 taken 534894 times.
✓ Branch 4 taken 7092 times.
✓ Branch 5 taken 1206 times.
943762 if(mainguy && clk==0 && misc==0)
7823 {
7824 1206 setupscreen();
7825 1206 misc = 1;
7826 1206 }
7827
7828
4/4
✓ Branch 0 taken 543192 times.
✓ Branch 1 taken 400570 times.
✓ Branch 2 taken 542862 times.
✓ Branch 3 taken 330 times.
943762 if(mainguy && fadeclk==0)
7829 330 return true;
7830
7831 943432 hp=256; // good guys never die...
7832
7833
4/4
✓ Branch 0 taken 922 times.
✓ Branch 1 taken 942510 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 16 times.
943432 if(hclk && !clk2)
7834 {
7835 // but if they get hit...
7836 16 ++clk2; // only do this once
7837
7838
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 7 times.
16 if(!get_qr(qr_NOGUYFIRES))
7839 {
7840 7 addenemy(screen_spawned,BSZ?64:72,68,eSHOOTFBALL,0);
7841 7 addenemy(screen_spawned,BSZ?176:168,68,eSHOOTFBALL,0);
7842 7 }
7843 16 }
7844
7845 943432 return enemy::animate(index);
7846 943762 }
7847
7848 947535 void guy::draw(BITMAP *dest)
7849 {
7850 947535 update_enemy_frame();
7851
7852
6/6
✓ Branch 0 taken 546756 times.
✓ Branch 1 taken 400779 times.
✓ Branch 2 taken 22911 times.
✓ Branch 3 taken 523845 times.
✓ Branch 4 taken 11064 times.
✓ Branch 5 taken 11847 times.
947535 if(!mainguy || fadeclk<0 || fadeclk&1)
7853 935688 enemy::draw(dest);
7854 947535 }
7855
7856 760 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7857 760 {
7858 760 clk4=0;
7859
4/8
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 760 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 760 times.
✗ Branch 7 not taken.
760 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7860 // Spawn type
7861
2/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 760 times.
760 if(flags & guy_fade_flicker)
7862 {
7863 clk=0;
7864 superman = 1;
7865 fading=fade_flicker;
7866 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7867 dir=down;
7868
7869 if(!canmove(down,(zfix)8,spw_none,false))
7870 clk3=int32_t(13.0/step);
7871 }
7872
3/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 676 times.
✓ Branch 3 taken 84 times.
760 else if(flags & guy_fade_instant)
7873 {
7874 84 clk=0;
7875 84 }
7876
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
760 if (SIZEflags != 0) init_size_flags();;
7877 760 }
7878
7879 167472 bool eFire::animate(int32_t index)
7880 {
7881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 167472 times.
167472 if(switch_hooked) return enemy::animate(index);
7882
2/4
✓ Branch 0 taken 167472 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 167472 times.
167472 if(fallclk||drownclk) return enemy::animate(index);
7883
2/2
✓ Branch 0 taken 165756 times.
✓ Branch 1 taken 1716 times.
167472 if(fading)
7884 {
7885
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1715 times.
1716 if(++clk4 > 60)
7886 {
7887 1 clk4=0;
7888 1 superman=0;
7889 1 fading=0;
7890
7891
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flags&guy_armos && z==0 && fakez==0)
7892 removearmos(x,y,ffcactivated);
7893
7894 1 clk2=0;
7895
7896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!canmove(down,(zfix)8,spw_none,false))
7897 {
7898 1 dir=0;
7899 1 y = TRUNCATE_TILE(y.getInt());
7900 1 }
7901
7902 1 return Dead(index);
7903 }
7904
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1715 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1715 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
7905 removearmos(x,y,ffcactivated);
7906 1715 }
7907
7908 167471 return enemy::animate(index);
7909 167472 }
7910
7911 351659 void eFire::draw(BITMAP *dest)
7912 {
7913 351659 update_enemy_frame();
7914 351659 enemy::draw(dest);
7915 351659 }
7916
7917 415 int32_t eFire::takehit(weapon *w, weapon* realweap)
7918 {
7919 415 int32_t wpnId = w->id;
7920 415 int32_t wpnDir = w->dir;
7921
7922
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
415 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7923 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
7924 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
7925 {
7926 shield = false;
7927 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
7928
7929 if(get_qr(qr_BRKNSHLDTILES))
7930 o_tile=s_tile;
7931 }
7932
7933 415 int32_t ret = enemy::takehit(w,realweap);
7934 415 return ret;
7935 }
7936
7937 void eFire::break_shield()
7938 {
7939 if(!shield)
7940 return;
7941
7942 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
7943 shield=false;
7944
7945 if(get_qr(qr_BRKNSHLDTILES))
7946 o_tile=s_tile;
7947 }
7948
7949 void eFire::repair_shield()
7950 {
7951 if (shield)
7952 return;
7953
7954 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
7955 return;
7956
7957 shield = true;
7958
7959 if (get_qr(qr_BRKNSHLDTILES))
7960 {
7961 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
7962 else o_tile = d->tile;
7963 }
7964 }
7965
7966 7630 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7967 7630 {
7968 7630 clk4=0;
7969
4/8
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7630 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7630 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7630 times.
✗ Branch 7 not taken.
7630 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7970
7971 // Spawn type
7972
2/4
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7630 times.
7630 if(flags & guy_fade_flicker)
7973 {
7974 clk=0;
7975 superman = 1;
7976 fading=fade_flicker;
7977 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7978 dir=down;
7979
7980 if(!canmove(down,(zfix)8,spw_none,false))
7981 clk3=int32_t(13.0/step);
7982 }
7983
3/4
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6443 times.
✓ Branch 3 taken 1187 times.
7630 else if(flags & guy_fade_instant)
7984 {
7985 1187 clk=0;
7986 1187 }
7987
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7623 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7630 if (SIZEflags != 0) init_size_flags();;
7988 7630 }
7989
7990 1981512 bool eOther::animate(int32_t index)
7991 {
7992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1981512 times.
1981512 if(switch_hooked) return enemy::animate(index);
7993
3/4
✓ Branch 0 taken 1979926 times.
✓ Branch 1 taken 1586 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1979926 times.
1981512 if(fallclk||drownclk) return enemy::animate(index);
7994
2/2
✓ Branch 0 taken 1971390 times.
✓ Branch 1 taken 8536 times.
1979926 if(fading)
7995 {
7996
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 8507 times.
8536 if(++clk4 > 60)
7997 {
7998 29 clk4=0;
7999 29 superman=0;
8000 29 fading=0;
8001
8002
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
29 if(flags&guy_armos && z==0 && fakez==0)
8003 removearmos(x,y,ffcactivated);
8004
8005 29 clk2=0;
8006
8007
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 2 times.
29 if(!canmove(down,(zfix)8,spw_none,false))
8008 {
8009 2 dir=0;
8010 2 y = TRUNCATE_TILE(y.getInt());
8011 2 }
8012
8013 29 return Dead(index);
8014 }
8015
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8507 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8507 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8016 removearmos(x,y,ffcactivated);
8017 8507 }
8018
8019 1979897 return enemy::animate(index);
8020 1981512 }
8021
8022 2087673 void eOther::draw(BITMAP *dest)
8023 {
8024 2087673 update_enemy_frame();
8025 2087673 enemy::draw(dest);
8026 2087673 }
8027
8028 14773 int32_t eOther::takehit(weapon *w, weapon* realweap)
8029 {
8030 14773 int32_t wpnId = w->id;
8031 14773 int32_t wpnDir = w->dir;
8032
8033
3/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 14731 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
14773 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8034 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8035 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8036 {
8037 shield = false;
8038 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8039
8040 if(get_qr(qr_BRKNSHLDTILES))
8041 o_tile=s_tile;
8042 }
8043
8044 14773 int32_t ret = enemy::takehit(w,realweap);
8045 14773 return ret;
8046 }
8047
8048 void eOther::break_shield()
8049 {
8050 if(!shield)
8051 return;
8052
8053 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8054 shield=false;
8055
8056 if(get_qr(qr_BRKNSHLDTILES))
8057 o_tile=s_tile;
8058 }
8059
8060 void eOther::repair_shield()
8061 {
8062 if (shield)
8063 return;
8064
8065 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8066 return;
8067
8068 shield = true;
8069
8070 if (get_qr(qr_BRKNSHLDTILES))
8071 {
8072 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8073 else o_tile = d->tile;
8074 }
8075 }
8076
8077 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8078 {
8079 clk4=0;
8080 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8081
8082 // Spawn type
8083 if(flags & guy_fade_flicker)
8084 {
8085 clk=0;
8086 superman = 1;
8087 fading=fade_flicker;
8088 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8089 dir=down;
8090
8091 if(!canmove(down,(zfix)8,spw_none,false))
8092 clk3=int32_t(13.0/step);
8093 }
8094 else if(flags & guy_fade_instant)
8095 {
8096 clk=0;
8097 }
8098 if (SIZEflags != 0) init_size_flags();;
8099 }
8100
8101 bool eScript::animate(int32_t index)
8102 {
8103 if(switch_hooked) return enemy::animate(index);
8104 if(fallclk||drownclk) return enemy::animate(index);
8105 if(fading)
8106 {
8107 if(++clk4 > 60)
8108 {
8109 clk4=0;
8110 superman=0;
8111 fading=0;
8112
8113 if(flags&guy_armos && z==0 && fakez==0)
8114 removearmos(x,y,ffcactivated);
8115
8116 clk2=0;
8117
8118 if(!canmove(down,(zfix)8,spw_none,false))
8119 {
8120 dir=0;
8121 y = TRUNCATE_TILE(y.getInt());
8122 }
8123
8124 return Dead(index);
8125 }
8126 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8127 removearmos(x,y,ffcactivated);
8128 }
8129
8130 return enemy::animate(index);
8131 }
8132
8133 void eScript::draw(BITMAP *dest)
8134 {
8135 update_enemy_frame();
8136 enemy::draw(dest);
8137 }
8138
8139 int32_t eScript::takehit(weapon *w, weapon* realweap)
8140 {
8141 int32_t wpnId = w->id;
8142 int32_t wpnDir = w->dir;
8143
8144 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8145 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8146 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8147 {
8148 shield = false;
8149 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8150
8151 if(get_qr(qr_BRKNSHLDTILES))
8152 o_tile=s_tile;
8153 }
8154
8155 int32_t ret = enemy::takehit(w,realweap);
8156 return ret;
8157 }
8158
8159 void eScript::break_shield()
8160 {
8161 if(!shield)
8162 return;
8163
8164 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8165 shield=false;
8166
8167 if(get_qr(qr_BRKNSHLDTILES))
8168 o_tile=s_tile;
8169 }
8170
8171 void eScript::repair_shield()
8172 {
8173 if (shield)
8174 return;
8175
8176 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8177 return;
8178
8179 shield = true;
8180
8181 if (get_qr(qr_BRKNSHLDTILES))
8182 {
8183 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8184 else o_tile = d->tile;
8185 }
8186 }
8187
8188
8189 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8190 {
8191 clk4=0;
8192 hyofs = -32768; //No hitbox initially.
8193 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8194
8195 // Spawn type
8196 if(flags & guy_fade_flicker)
8197 {
8198 clk=0;
8199 superman = 1;
8200 fading=fade_flicker;
8201 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8202 dir=down;
8203
8204 if(!canmove(down,(zfix)8,spw_none,false))
8205 clk3=int32_t(13.0/step);
8206 }
8207 else if(flags & guy_fade_instant)
8208 {
8209 clk=0;
8210 }
8211 if (SIZEflags != 0) init_size_flags();;
8212 }
8213
8214 bool eFriendly::animate(int32_t index)
8215 {
8216 if(switch_hooked) return enemy::animate(index);
8217 if(fallclk||drownclk) return enemy::animate(index);
8218 if(fading)
8219 {
8220 if(++clk4 > 60)
8221 {
8222 clk4=0;
8223 superman=0;
8224 fading=0;
8225
8226 if(flags&guy_armos && z==0 && fakez==0)
8227 removearmos(x,y,ffcactivated);
8228
8229 clk2=0;
8230
8231 if(!canmove(down,(zfix)8,spw_none,false))
8232 {
8233 dir=0;
8234 y = TRUNCATE_TILE(y.getInt());
8235 }
8236
8237 return Dead(index);
8238 }
8239 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8240 removearmos(x,y,ffcactivated);
8241 }
8242
8243 return enemy::animate(index);
8244 }
8245
8246 void eFriendly::draw(BITMAP *dest)
8247 {
8248 update_enemy_frame();
8249 enemy::draw(dest);
8250 }
8251
8252 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
8253 {
8254 int32_t wpnId = w->id;
8255 int32_t wpnDir = w->dir;
8256
8257 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8258 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8259 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8260 {
8261 shield = false;
8262 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8263
8264 if(get_qr(qr_BRKNSHLDTILES))
8265 o_tile=s_tile;
8266 }
8267
8268 int32_t ret = enemy::takehit(w,realweap);
8269 return ret;
8270 }
8271
8272 void eFriendly::break_shield()
8273 {
8274 if(!shield)
8275 return;
8276
8277 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8278 shield=false;
8279
8280 if(get_qr(qr_BRKNSHLDTILES))
8281 o_tile=s_tile;
8282 }
8283
8284 void eFriendly::repair_shield()
8285 {
8286 if (shield)
8287 return;
8288
8289 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8290 return;
8291
8292 shield = true;
8293
8294 if (get_qr(qr_BRKNSHLDTILES))
8295 {
8296 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8297 else o_tile = d->tile;
8298 }
8299 }
8300
8301
8302 780032 void enemy::removearmos(int32_t ax,int32_t ay, std::optional<ffc_handle_t> ffcactive)
8303 {
8304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780032 times.
780032 if (ffcactive)
8305 {
8306 removearmosffc(*ffcactive);
8307 return;
8308 }
8309
2/2
✓ Branch 0 taken 779016 times.
✓ Branch 1 taken 1016 times.
780032 if(did_armos)
8310 {
8311 779016 return;
8312 }
8313
8314 1016 auto rpos_handle = get_rpos_handle_for_world_xy(ax, ay, 0);
8315 1016 mapscr* scr = rpos_handle.scr;
8316 1016 ax = TRUNCATE_TILE(ax);
8317 1016 ay = TRUNCATE_TILE(ay);
8318
8319 1016 did_armos=true;
8320 1016 int32_t cd = rpos_handle.pos;
8321 1016 int32_t f = rpos_handle.sflag();
8322 1016 int32_t f2 = rpos_handle.cflag();
8323
8324
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 176 times.
1016 if (rpos_handle.ctype() != cARMOS)
8325 {
8326 840 return;
8327 }
8328
8329 176 scr->data[cd] = scr->undercombo;
8330 176 scr->cset[cd] = scr->undercset;
8331 176 scr->sflag[cd] = 0;
8332
8333
3/4
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154 times.
176 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
8334 {
8335 22 scr->data[cd] = scr->secretcombo[sSTAIRS];
8336 22 scr->cset[cd] = scr->secretcset[sSTAIRS];
8337 22 scr->sflag[cd]=scr->secretflag[sSTAIRS];
8338 22 sfx(scr->secretsfx);
8339 22 }
8340
8341
3/4
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 173 times.
176 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
8342 {
8343
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN))
8344 {
8345 3 additem(ax,ay,scr->catchall, (ipONETIME2 + ipBIGRANGE) | ((scr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8346 3 sfx(scr->secretsfx);
8347 3 }
8348 3 }
8349
8350 176 putcombo(scrollbuf,ax,ay,scr->data[cd],scr->cset[cd]);
8351 780032 }
8352
8353 void enemy::removearmosffc(const ffc_handle_t& ffc_handle)
8354 {
8355 if(did_armos)
8356 {
8357 return;
8358 }
8359
8360 did_armos=true;
8361 ffcdata& ffc = *ffc_handle.ffc;
8362 mapscr* scr = ffc_handle.scr;
8363 auto& cmb = ffc_handle.combo();
8364 int32_t f2 = cmb.flag;
8365
8366 if(cmb.type!=cARMOS)
8367 {
8368 return;
8369 }
8370
8371 ffc_handle.set_data(scr->undercombo);
8372 ffc_handle.set_cset(scr->undercset);
8373
8374 if(f2 == mfARMOS_SECRET)
8375 {
8376 ffc_handle.set_data(scr->secretcombo[sSTAIRS]);
8377 ffc_handle.set_cset(scr->secretcset[sSTAIRS]);
8378 sfx(scr->secretsfx);
8379 }
8380
8381 if(f2 == mfARMOS_ITEM)
8382 {
8383 if(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN))
8384 {
8385 additem(ffc.x,ffc.y,scr->catchall, (ipONETIME2 + ipBIGRANGE) | ((scr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8386 sfx(scr->secretsfx);
8387 }
8388 }
8389
8390 putcombo(scrollbuf,ffc.x,ffc.y,ffc_handle.data(),ffc.cset);
8391 }
8392
8393
8394 461 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8395 461 {
8396 461 fading=fade_flicker;
8397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8398 461 dir=12;
8399 461 movestatus=1;
8400
1/2
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
461 step=0;
8401 461 clk=0;
8402 461 clk4=0;
8403
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if (SIZEflags != 0) init_size_flags();;
8404 461 }
8405
8406 117025 bool eGhini::animate(int32_t index)
8407 {
8408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117025 times.
117025 if(switch_hooked) return enemy::animate(index);
8409
2/4
✓ Branch 0 taken 117025 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 117025 times.
117025 if(fallclk||drownclk) return enemy::animate(index);
8410
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 116975 times.
117025 if(dying)
8411 50 return Dead(index);
8412
8413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116975 times.
116975 if(dmisc1)
8414 {
8415
2/2
✓ Branch 0 taken 89752 times.
✓ Branch 1 taken 27223 times.
116975 if(misc)
8416 {
8417
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 if(clk4>160)
8418 54853 misc=2;
8419
8420
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
8421 89752 removearmos(x,y,ffcactivated);
8422 89752 }
8423
2/2
✓ Branch 0 taken 26798 times.
✓ Branch 1 taken 425 times.
27223 else if(clk4>=60)
8424 {
8425 425 misc=1;
8426 425 clk3=32;
8427 425 fading=0;
8428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if (ffcactivated)
8429 {
8430 activation_counters_ffc[ffcactivated->id] = 0;
8431 removearmosffc(*ffcactivated);
8432 }
8433 else
8434 {
8435 425 rpos_t rpos = COMBOPOS_REGION_B(x, y);
8436
1/2
✓ Branch 0 taken 425 times.
✗ Branch 1 not taken.
425 if (rpos != rpos_t::None)
8437 {
8438 425 activation_counters[(int)rpos] = 0;
8439 425 removearmos(x,y);
8440 425 }
8441 }
8442 425 }
8443 116975 }
8444
8445 116975 clk4++;
8446
8447 116975 return enemy::animate(index);
8448 117025 }
8449
8450 238808 void eGhini::draw(BITMAP *dest)
8451 {
8452 238808 update_enemy_frame();
8453 238808 enemy::draw(dest);
8454 238808 }
8455
8456 2 void eGhini::kickbucket()
8457 {
8458 2 hp=-1000; // don't call death_sfx()
8459 2 }
8460
8461
2/4
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5212 times.
✗ Branch 3 not taken.
10424 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8462 5212 {
8463
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 old_y=y;
8464 5212 dir=down;
8465 5212 misc=1;
8466 5212 clk=-15;
8467
8468
2/2
✓ Branch 0 taken 2649 times.
✓ Branch 1 taken 2563 times.
5212 if(!BSZ)
8469
1/2
✓ Branch 0 taken 2649 times.
✗ Branch 1 not taken.
2649 clk*=zc_oldrand()%3+1;
8470
8471 // avoid divide by 0 errors
8472
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 if(dmisc1 == 0)
8473 dmisc1 = 24;
8474
8475
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 if(dmisc2 == 0)
8476 dmisc2 = 3;
8477
8478 //nets+760;
8479
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5212 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5212 if (SIZEflags != 0) init_size_flags();;
8480 5212 }
8481
8482 1436590 bool eTektite::animate(int32_t index)
8483 {
8484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1436590 times.
1436590 if(switch_hooked) return enemy::animate(index);
8485
4/4
✓ Branch 0 taken 1427644 times.
✓ Branch 1 taken 8946 times.
✓ Branch 2 taken 8946 times.
✓ Branch 3 taken 1425242 times.
1436590 if(fallclk||drownclk) return enemy::animate(index);
8486
2/2
✓ Branch 0 taken 26667 times.
✓ Branch 1 taken 1398575 times.
1425242 if(dying)
8487 26667 return Dead(index);
8488
8489
2/2
✓ Branch 0 taken 1361472 times.
✓ Branch 1 taken 37103 times.
1398575 if(clk==0)
8490 {
8491 37103 removearmos(x,y,ffcactivated);
8492 37103 }
8493
8494
2/2
✓ Branch 0 taken 1057392 times.
✓ Branch 1 taken 341183 times.
1398575 if(get_qr(qr_ENEMIESZAXIS))
8495 {
8496 341183 y=floor_y;
8497 341183 }
8498
8499
9/10
✓ Branch 0 taken 1283739 times.
✓ Branch 1 taken 114836 times.
✓ Branch 2 taken 1270175 times.
✓ Branch 3 taken 13564 times.
✓ Branch 4 taken 1270175 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11176 times.
✓ Branch 7 taken 1258999 times.
✓ Branch 8 taken 11960 times.
✓ Branch 9 taken 21878 times.
1398575 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
8500 {
8501
4/4
✓ Branch 0 taken 20260 times.
✓ Branch 1 taken 421702 times.
✓ Branch 2 taken 345150 times.
✓ Branch 3 taken 493765 times.
1280877 switch(misc)
8502 {
8503 case 0: // normal
8504
2/2
✓ Branch 0 taken 410469 times.
✓ Branch 1 taken 11233 times.
421702 if (!zc::math::SafeMod(zc_oldrand(), dmisc1))
8505 {
8506 11233 misc=1;
8507 11233 clk2=32;
8508 11233 }
8509
8510 421702 break;
8511
8512 case 1: // waiting to pounce
8513
2/2
✓ Branch 0 taken 324515 times.
✓ Branch 1 taken 20635 times.
345150 if(--clk2<=0)
8514 {
8515 20635 int32_t r=zc_oldrand();
8516 20635 misc=2;
8517 20635 step=0-(zslongToFix(dstep*100)); // initial speed
8518 20635 clk3=(r&1)+2; // left or right
8519 20635 clk2start=clk2=(r&31)+10; // flight time
8520
8521
2/2
✓ Branch 0 taken 18212 times.
✓ Branch 1 taken 2423 times.
20635 if(y<32) clk2+=2; // make them come down from top of screen
8522
8523
2/2
✓ Branch 0 taken 15717 times.
✓ Branch 1 taken 4918 times.
20635 if(y>world_h-64) clk2-=2; // make them go back up
8524
8525 20635 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
8526 20635 }
8527
8528 345150 break;
8529
8530 case 2: // in flight
8531 493765 move(step);
8532
8533
2/2
✓ Branch 0 taken 234357 times.
✓ Branch 1 taken 259408 times.
493765 if(step>0) //going down
8534 {
8535
2/2
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 233725 times.
234357 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
8536 {
8537 632 step=0-step;
8538 632 }
8539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233725 times.
233725 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
8540 {
8541 step=0-step;
8542 }
8543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233725 times.
233725 else if(ispitfall(x+8,y+16))
8544 {
8545 step=0-step;
8546 }
8547
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 233678 times.
233725 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
8548 {
8549 47 step=0-step;
8550 47 }
8551
2/2
✓ Branch 0 taken 233667 times.
✓ Branch 1 taken 11 times.
233678 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
8552 {
8553 11 step=0-step;
8554 11 }
8555 234357 }
8556
2/2
✓ Branch 0 taken 15166 times.
✓ Branch 1 taken 244242 times.
259408 else if(step<0)
8557 {
8558
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 243804 times.
244242 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
8559 {
8560 438 step=0-step;
8561 438 }
8562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243804 times.
243804 else if(COMBOTYPE(x+8,y)==cNOENEMY)
8563 {
8564 step=0-step;
8565 }
8566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243804 times.
243804 else if(ispitfall(x+8,y))
8567 {
8568 step=0-step;
8569 }
8570
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 243783 times.
243804 else if(MAPFLAG(x+8,y)==mfNOENEMY)
8571 {
8572 21 step=0-step;
8573 21 }
8574
2/2
✓ Branch 0 taken 243764 times.
✓ Branch 1 taken 19 times.
243783 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
8575 {
8576 19 step=0-step;
8577 19 }
8578 244242 }
8579
8580
2/2
✓ Branch 0 taken 244331 times.
✓ Branch 1 taken 249434 times.
493765 if(clk3==left)
8581 {
8582
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 244056 times.
244331 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
8583 {
8584 275 clk3^=1;
8585 275 }
8586
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 244050 times.
244056 else if(COMBOTYPE(x,y+8)==cNOENEMY)
8587 {
8588 6 clk3^=1;
8589 6 }
8590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244050 times.
244050 else if(ispitfall(x,y+8))
8591 {
8592 clk3^=1;
8593 }
8594
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 244020 times.
244050 else if(MAPFLAG(x,y+8)==mfNOENEMY)
8595 {
8596 30 clk3^=1;
8597 30 }
8598
2/2
✓ Branch 0 taken 244008 times.
✓ Branch 1 taken 12 times.
244020 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
8599 {
8600 12 clk3^=1;
8601 12 }
8602 244331 }
8603 else
8604 {
8605
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 249158 times.
249434 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
8606 {
8607 276 clk3^=1;
8608 276 }
8609
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 249146 times.
249158 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
8610 {
8611 12 clk3^=1;
8612 12 }
8613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249146 times.
249146 else if(ispitfall(x+16,y+8))
8614 {
8615 clk3^=1;
8616 }
8617
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 249141 times.
249146 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
8618 {
8619 5 clk3^=1;
8620 5 }
8621
2/2
✓ Branch 0 taken 249129 times.
✓ Branch 1 taken 12 times.
249141 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
8622 {
8623 12 clk3^=1;
8624 12 }
8625 }
8626
8627 493765 --c;
8628
8629
4/4
✓ Branch 0 taken 151531 times.
✓ Branch 1 taken 342234 times.
✓ Branch 2 taken 320688 times.
✓ Branch 3 taken 173077 times.
493765 if(c<0 && step<zslongToFix(dstep*100))
8630 {
8631 173077 step+=zslongToFix(dmisc3*100);
8632 173077 }
8633
8634 493765 int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0;
8635
8636
2/2
✓ Branch 0 taken 493043 times.
✓ Branch 1 taken 722 times.
493765 if(x<=16-nb) clk3=right;
8637
8638
2/2
✓ Branch 0 taken 492773 times.
✓ Branch 1 taken 992 times.
493765 if(x>=world_w-32+nb) clk3=left;
8639
8640 493765 x += (clk3==left) ? -1 : 1;
8641
8642
4/4
✓ Branch 0 taken 29039 times.
✓ Branch 1 taken 464726 times.
✓ Branch 2 taken 10130 times.
✓ Branch 3 taken 454596 times.
493765 if((--clk2<=0 && y>=16-nb) || y>=world_h-32+nb)
8643 {
8644
4/4
✓ Branch 0 taken 1621 times.
✓ Branch 1 taken 17288 times.
✓ Branch 2 taken 1436 times.
✓ Branch 3 taken 185 times.
39169 if(y>=world_h-32+nb && get_qr(qr_ENEMIESZAXIS))
8645 {
8646 185 step=0-step;
8647 185 y--;
8648 185 }
8649
2/2
✓ Branch 0 taken 5796 times.
✓ Branch 1 taken 12928 times.
18724 else if (zc::math::SafeMod(zc_oldrand(), dmisc2)) //land and wait
8650 {
8651 12928 clk=misc=0;
8652 12928 } //land and jump again
8653 else
8654 {
8655 5796 misc=1;
8656 5796 clk2=0;
8657 }
8658 18909 }
8659
8660 473505 break;
8661 } // switch
8662 1260617 }
8663
8664
4/4
✓ Branch 0 taken 341183 times.
✓ Branch 1 taken 1059794 times.
✓ Branch 2 taken 231206 times.
✓ Branch 3 taken 109977 times.
1400977 if(get_qr(qr_ENEMIESZAXIS) && misc==2)
8665 {
8666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109977 times.
109977 if (moveflags & move_use_fake_z)
8667 {
8668 int32_t tempy = floor_y;
8669 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
8670 floor_y = y;
8671 y=tempy-fakez;
8672 old_y = y;
8673 }
8674 else
8675 {
8676 109977 int32_t tempy = floor_y;
8677
6/6
✓ Branch 0 taken 55216 times.
✓ Branch 1 taken 54761 times.
✓ Branch 2 taken 104073 times.
✓ Branch 3 taken 5904 times.
✓ Branch 4 taken 50747 times.
✓ Branch 5 taken 53326 times.
109977 z=zc_max(0,zc_min(clk2start-clk2,clk2));
8678 109977 floor_y = y;
8679 109977 y=tempy-z;
8680 109977 old_y = y;
8681 }
8682 109977 }
8683
8684
4/4
✓ Branch 0 taken 13564 times.
✓ Branch 1 taken 1387413 times.
✓ Branch 2 taken 2927 times.
✓ Branch 3 taken 10637 times.
1400977 if(stunclk && (clk&31)==1)
8685 10637 clk=0;
8686
8687 1400977 return enemy::animate(index);
8688 1427644 }
8689
8690 809450 void eTektite::drawshadow(BITMAP *dest,bool translucent)
8691 {
8692
5/6
✓ Branch 0 taken 632172 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 632172 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 606981 times.
✓ Branch 5 taken 25191 times.
809450 if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS))
8693 25191 return;
8694
8695 784259 int32_t tempy=yofs;
8696 784259 int32_t fdiv = frate/4;
8697
1/2
✓ Branch 0 taken 784259 times.
✗ Branch 1 not taken.
784259 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
8698
1/2
✓ Branch 0 taken 784259 times.
✗ Branch 1 not taken.
784259 int32_t f2=get_qr(qr_NEWENEMYTILES)?
8699 784259 efrate:((clk>=(frate>>1))?1:0);
8700 784259 flip = 0;
8701 784259 shadowtile = wpnsbuf[spr_shadow].tile;
8702
8703
1/2
✓ Branch 0 taken 784259 times.
✗ Branch 1 not taken.
784259 if(get_qr(qr_NEWENEMYTILES))
8704 {
8705
2/2
✓ Branch 0 taken 581728 times.
✓ Branch 1 taken 202531 times.
784259 if(misc==0)
8706 {
8707 202531 shadowtile+=f2;
8708 202531 }
8709
2/2
✓ Branch 0 taken 259363 times.
✓ Branch 1 taken 322365 times.
581728 else if(misc!=1)
8710 322365 shadowtile+=2;
8711 784259 }
8712 else
8713 {
8714 if(misc==0)
8715 {
8716 shadowtile += f2 ? 1 : 0;
8717 }
8718 else if(misc!=1)
8719 {
8720 ++shadowtile;
8721 }
8722 }
8723
8724 784259 yofs+=8;
8725
8726
4/4
✓ Branch 0 taken 606981 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 344816 times.
✓ Branch 3 taken 262165 times.
784259 if(!get_qr(qr_ENEMIESZAXIS) && misc==2)
8727 {
8728
6/6
✓ Branch 0 taken 134327 times.
✓ Branch 1 taken 127838 times.
✓ Branch 2 taken 244709 times.
✓ Branch 3 taken 17456 times.
✓ Branch 4 taken 123717 times.
✓ Branch 5 taken 120992 times.
262165 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
8729 262165 }
8730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 784259 times.
784259 if(!shadow_overpit(this))
8731 784259 enemy::drawshadow(dest,translucent);
8732 784259 yofs=tempy;
8733 809450 }
8734
8735 2052032 void eTektite::draw(BITMAP *dest)
8736 {
8737 2052032 update_enemy_frame();
8738 2052032 enemy::draw(dest);
8739 2052032 }
8740
8741 732 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8742 732 {
8743
2/4
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 732 times.
✗ Branch 3 not taken.
732 step=zslongToFix(guysbuf[id&0xFFF].step*100);
8744 732 superman=1;
8745 732 dir=8;
8746 732 hxofs=1000;
8747 732 mainguy=false;
8748 732 count_enemy=false;
8749
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
732 if (SIZEflags != 0) init_size_flags();;
8750 732 }
8751
8752 280245 bool eItemFairy::animate(int32_t index)
8753 {
8754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280245 times.
280245 if(switch_hooked) return enemy::animate(index);
8755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280245 times.
280245 if(dying)
8756 return Dead(index);
8757
8758 //if(clk>32)
8759 280245 misc=1;
8760 280245 bool w=watch;
8761 280245 watch=false;
8762 280245 variable_walk_8(misc?3:0,0,8,spw_floater);
8763 280245 watch=w;
8764
8765
2/2
✓ Branch 0 taken 1516 times.
✓ Branch 1 taken 278729 times.
280245 if(clk==0)
8766 {
8767 1516 removearmos(x,y,ffcactivated);
8768 1516 }
8769
8770 280245 return enemy::animate(index);
8771 280245 }
8772
8773 562846 void eItemFairy::draw(BITMAP *dest)
8774 {
8775 //these are here to bypass compiler warnings about unused arguments
8776 562846 dest=dest;
8777 562846 }
8778
8779 1825 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8780 1825 {
8781 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8782
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1825 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1825 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1825 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1825 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1825 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1825 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1825 times.
✗ Branch 19 not taken.
1825 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
8783 1825 dir=8;
8784 1825 movestatus=1;
8785 1825 clk=0;
8786
1/2
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
1825 step=0;
8787 //nets+720;
8788
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1825 if (SIZEflags != 0) init_size_flags();;
8789 1825 }
8790
8791 520615 bool ePeahat::animate(int32_t index)
8792 {
8793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 520615 times.
520615 if(switch_hooked) return enemy::animate(index);
8794
2/4
✓ Branch 0 taken 520615 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 520615 times.
520615 if(fallclk||drownclk) return enemy::animate(index);
8795
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 520537 times.
520615 if(slide())
8796 {
8797 78 update_current_screen();
8798 78 return false;
8799 }
8800
8801
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 519507 times.
520537 if(dying)
8802 1030 return Dead(index);
8803
8804
2/2
✓ Branch 0 taken 3083 times.
✓ Branch 1 taken 516424 times.
519507 if(clk==0)
8805 {
8806 3083 removearmos(x,y,ffcactivated);
8807 3083 }
8808
8809
4/4
✓ Branch 0 taken 516389 times.
✓ Branch 1 taken 3118 times.
✓ Branch 2 taken 253336 times.
✓ Branch 3 taken 263053 times.
519507 if(stunclk==0 && clk>96)
8810 263053 misc=1;
8811
8812
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
519507 if(!watch)
8813
2/2
✓ Branch 0 taken 171491 times.
✓ Branch 1 taken 345614 times.
517105 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
8814
8815
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 419489 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
519507 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
8816 {
8817
1/2
✓ Branch 0 taken 100018 times.
✗ Branch 1 not taken.
100018 if (moveflags & move_use_fake_z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8818 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8819 100018 }
8820
8821
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 1634 times.
519507 if(watch && get_qr(qr_PEAHATCLOCKVULN))
8822 1634 superman=0;
8823 else
8824
2/2
✓ Branch 0 taken 9811 times.
✓ Branch 1 taken 508062 times.
517873 superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0;
8825 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
8826
2/2
✓ Branch 0 taken 264937 times.
✓ Branch 1 taken 254570 times.
519507 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
8827 {
8828
2/2
✓ Branch 0 taken 261822 times.
✓ Branch 1 taken 3115 times.
264937 if ( stunclk ) --stunclk;
8829 264937 }
8830 254570 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
8831 //Pretty sure this was always an error. -Z ( 14FEB2019 )
8832
8833
8834
2/2
✓ Branch 0 taken 519267 times.
✓ Branch 1 taken 240 times.
519507 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
8835
8836 519507 return enemy::animate(index);
8837 520615 }
8838
8839 334520 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
8840 {
8841 334520 int32_t tempy=yofs;
8842 334520 flip = 0;
8843 334520 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
8844
8845
2/2
✓ Branch 0 taken 88089 times.
✓ Branch 1 taken 246431 times.
334520 if(!get_qr(qr_ENEMIESZAXIS))
8846 {
8847 246431 yofs+=8;
8848 246431 yofs+=int32_t(step/zslongToFix(dstep*10));
8849 246431 }
8850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334520 times.
334520 if(!shadow_overpit(this))
8851 334520 enemy::drawshadow(dest,translucent);
8852 334520 yofs=tempy;
8853 334520 }
8854
8855 1144330 void ePeahat::draw(BITMAP *dest)
8856 {
8857 1144330 update_enemy_frame();
8858 1144330 enemy::draw(dest);
8859 1144330 }
8860
8861 4136 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
8862 {
8863 4136 int32_t wpnId = w->id;
8864 4136 int32_t enemyHitWeapon = w->parentitem;
8865
8866
3/6
✓ Branch 0 taken 4136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4136 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4136 times.
4136 if(dying || clk<0 || hclk>0)
8867 return 0;
8868
8869
4/4
✓ Branch 0 taken 3381 times.
✓ Branch 1 taken 755 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 206 times.
4380 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
8870 // fire boomerang, for nailing peahats
8871
4/6
✓ Branch 0 taken 3381 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3137 times.
✓ Branch 3 taken 244 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 244 times.
3381 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
8872 3343 return 0;
8873
8874 // Time for a kludge...
8875 793 int32_t s = superman;
8876 793 superman = 0;
8877 793 int32_t ret = enemy::takehit(w,realweap);
8878 793 superman = s;
8879
8880 // Anyway...
8881
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 192 times.
793 if(stunclk == 160)
8882 {
8883 192 clk2=0;
8884 192 movestatus=0;
8885 192 misc=0;
8886 192 clk=0;
8887 192 step=0;
8888 192 }
8889
8890 793 return ret;
8891 4136 }
8892
8893 // auomatically kill off enemy (for rooms with ringleaders)
8894 void ePeahat::kickbucket()
8895 {
8896 hp=-1000; // don't call death_sfx()
8897 }
8898
8899 3942 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8900 3942 {
8901 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
8902
2/2
✓ Branch 0 taken 1795 times.
✓ Branch 1 taken 2147 times.
3942 if(dmisc1==0)
8903 {
8904 2147 misc=-1; //Line of Sight leevers
8905 2147 clk-=16;
8906 2147 }
8907 3942 clk3 = 0;
8908 //nets+1460;
8909 3942 temprule=(get_qr(qr_NEWENEMYTILES)) != 0;
8910 3942 submerged = false;
8911
1/4
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3942 if (SIZEflags != 0) init_size_flags();;
8912 3942 }
8913
8914 923 bool eLeever::isSubmerged() const
8915 {
8916 923 return misc <= 0;
8917 }
8918
8919 1018478 bool eLeever::animate(int32_t index)
8920 {
8921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1018478 times.
1018478 if(switch_hooked) return enemy::animate(index);
8922
3/4
✓ Branch 0 taken 1018123 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1018123 times.
1018478 if(fallclk||drownclk)
8923 {
8924 355 return enemy::animate(index);
8925 }
8926
2/2
✓ Branch 0 taken 31552 times.
✓ Branch 1 taken 986571 times.
1018123 if(dying)
8927 31552 return Dead(index);
8928
8929
2/2
✓ Branch 0 taken 941601 times.
✓ Branch 1 taken 44970 times.
986571 if(clk==0)
8930 {
8931 44970 removearmos(x,y,ffcactivated);
8932 44970 }
8933
8934
4/4
✓ Branch 0 taken 816947 times.
✓ Branch 1 taken 169624 times.
✓ Branch 2 taken 5265 times.
✓ Branch 3 taken 811682 times.
986571 if(clk>=0 && !slide())
8935 {
8936
2/2
✓ Branch 0 taken 337868 times.
✓ Branch 1 taken 473814 times.
811682 switch(dmisc1)
8937 {
8938 case 0: //line of sight
8939 case 2:
8940
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 124459 times.
✓ Branch 2 taken 49109 times.
✓ Branch 3 taken 35464 times.
✓ Branch 4 taken 15780 times.
✓ Branch 5 taken 101784 times.
✓ Branch 6 taken 4365 times.
✓ Branch 7 taken 6907 times.
337868 switch(misc) //is this leever active
8941 {
8942 case -1: //submerged
8943 {
8944
4/6
✓ Branch 0 taken 6382 times.
✓ Branch 1 taken 118077 times.
✓ Branch 2 taken 6382 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6382 times.
124459 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
8945
4/4
✓ Branch 0 taken 10299 times.
✓ Branch 1 taken 114160 times.
✓ Branch 2 taken 10261 times.
✓ Branch 3 taken 38 times.
124459 if((dmisc1==2)&&(zc_oldrand()&255))
8946 {
8947 10261 break;
8948 }
8949
8950 114198 int32_t active=0;
8951
8952
2/2
✓ Branch 0 taken 783342 times.
✓ Branch 1 taken 114198 times.
897540 for(int32_t i=0; i<guys.Count(); i++)
8953 {
8954
4/4
✓ Branch 0 taken 627294 times.
✓ Branch 1 taken 156048 times.
✓ Branch 2 taken 401598 times.
✓ Branch 3 taken 225696 times.
783342 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
8955 {
8956 225696 ++active;
8957 225696 }
8958 783342 }
8959
8960
2/2
✓ Branch 0 taken 112327 times.
✓ Branch 1 taken 1871 times.
114198 if(active<((dmisc1==2)?1:2))
8961 {
8962 1871 misc=0; //activate this one
8963 1871 clk3=1; //This needs to be set so that it knows that it's being emerged of its own will and not because it got stunned.
8964 1871 }
8965 }
8966 114198 break;
8967
8968 case 0:
8969 {
8970
8971
4/6
✓ Branch 0 taken 11920 times.
✓ Branch 1 taken 37189 times.
✓ Branch 2 taken 11920 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11920 times.
49109 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
8972 {
8973 misc=1;
8974 clk2=0;
8975 }
8976
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 49052 times.
49109 else if (clk3<=0)
8977 {
8978 57 misc = -1;
8979 57 break;
8980 }
8981 49052 int32_t s=0;
8982
8983
2/2
✓ Branch 0 taken 273250 times.
✓ Branch 1 taken 49052 times.
322302 for(int32_t i=0; i<guys.Count(); i++)
8984 {
8985
4/4
✓ Branch 0 taken 164314 times.
✓ Branch 1 taken 108936 times.
✓ Branch 2 taken 156432 times.
✓ Branch 3 taken 7882 times.
273250 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
8986 {
8987 7882 ++s;
8988 7882 }
8989 273250 }
8990
8991
2/2
✓ Branch 0 taken 7882 times.
✓ Branch 1 taken 41170 times.
49052 if(s>0)
8992 {
8993 7882 break;
8994 }
8995
8996 41170 int32_t d2=zc_oldrand()&1;
8997
8998
2/2
✓ Branch 0 taken 14509 times.
✓ Branch 1 taken 26661 times.
41170 if(HeroDir()>=left)
8999 {
9000 26661 d2+=2;
9001 26661 }
9002
9003
4/4
✓ Branch 0 taken 39722 times.
✓ Branch 1 taken 1448 times.
✓ Branch 2 taken 663 times.
✓ Branch 3 taken 39059 times.
41170 if(canplace(d2) || canplace(d2^1))
9004 {
9005 2111 misc=1;
9006 2111 clk2=0;
9007 2111 clk=0;
9008 2111 }
9009 }
9010 41170 break;
9011
9012 case 1:
9013
9014
7/8
✓ Branch 0 taken 33397 times.
✓ Branch 1 taken 2067 times.
✓ Branch 2 taken 3596 times.
✓ Branch 3 taken 29801 times.
✓ Branch 4 taken 3596 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 3595 times.
35464 if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
9015
9016 35464 break;
9017
9018 case 2:
9019
9020
7/8
✓ Branch 0 taken 13865 times.
✓ Branch 1 taken 1915 times.
✓ Branch 2 taken 1503 times.
✓ Branch 3 taken 12362 times.
✓ Branch 4 taken 1503 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1502 times.
15780 if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
9021
9022 15780 break;
9023
9024 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
9025 case 3:
9026
9027
5/6
✓ Branch 0 taken 98195 times.
✓ Branch 1 taken 3589 times.
✓ Branch 2 taken 98195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2727 times.
✓ Branch 5 taken 95468 times.
101784 if(stunclk || frozenclock || watch) break;
9028
9029
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 95326 times.
95468 if(scored) dir^=1;
9030
9031
2/2
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 94963 times.
95468 if(!canmove(dir,false)) misc=4;
9032 94963 else move(zslongToFix(dstep*100));
9033
9034 95468 break;
9035
9036 case 4:
9037
4/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 3755 times.
✓ Branch 2 taken 610 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 610 times.
4365 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
9038
2/2
✓ Branch 0 taken 3897 times.
✓ Branch 1 taken 468 times.
4365 if(--clk2<=16)
9039 {
9040 468 misc=5;
9041 468 clk=8;
9042 468 }
9043
9044 4365 break;
9045
9046 case 5:
9047
5/6
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 5897 times.
✓ Branch 2 taken 1010 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1009 times.
6907 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
9048
2/2
✓ Branch 0 taken 6497 times.
✓ Branch 1 taken 410 times.
6907 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
9049
9050 6907 break;
9051 } // switch(misc)
9052
9053 337868 break;
9054
9055 default: //random
9056 // step=d->misc3/100.0;
9057
9058 473814 step=zslongToFix(dmisc3*100);
9059
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
473814 if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
9060 else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9061 {
9062 if (clk2 < 48) clk2+=2;
9063 if (clk2 >= 300) clk2-=2;
9064 }
9065
9066
2/2
✓ Branch 0 taken 60840 times.
✓ Branch 1 taken 412974 times.
473814 if(clk2<32) misc=1;
9067
2/2
✓ Branch 0 taken 30244 times.
✓ Branch 1 taken 382730 times.
412974 else if(clk2<48) misc=2;
9068
2/2
✓ Branch 0 taken 289541 times.
✓ Branch 1 taken 93189 times.
382730 else if(clk2<300)
9069 {
9070 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
9071 {
9072 fix_coords();
9073 }*/
9074 289541 misc=3;
9075 289541 step = zslongToFix(dstep*100);
9076 289541 }
9077
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 84180 times.
93189 else if(clk2<316) misc=2;
9078
2/2
✓ Branch 0 taken 43755 times.
✓ Branch 1 taken 40425 times.
84180 else if(clk2<412) misc=1;
9079
2/2
✓ Branch 0 taken 40151 times.
✓ Branch 1 taken 274 times.
40425 else if(clk2<540)
9080 {
9081 40151 misc=0;
9082 40151 step=0;
9083 40151 }
9084 274 else clk2=0;
9085
9086
2/2
✓ Branch 0 taken 471961 times.
✓ Branch 1 taken 1853 times.
473814 if(clk2==48) clk=0;
9087
9088 // variable_walk(d->rate, d->homing, 0);
9089 473814 variable_walk(rate, homing, 0);
9090 473814 } // switch(dmisc1)
9091 811682 }
9092
9093 986571 hxofs=(misc>=2)?0:1000;
9094 986571 return enemy::animate(index);
9095 1018478 }
9096
9097 80892 bool eLeever::canplace(int32_t d2)
9098 {
9099 80892 int32_t nx=HeroX();
9100 80892 int32_t ny=HeroY();
9101
9102
2/2
✓ Branch 0 taken 28492 times.
✓ Branch 1 taken 52400 times.
80892 if(d2<left) ny=TRUNCATE_TILE(ny);
9103 52400 else nx=TRUNCATE_TILE(nx);
9104
9105
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14174 times.
✓ Branch 2 taken 14318 times.
✓ Branch 3 taken 26181 times.
✓ Branch 4 taken 26219 times.
80892 switch(d2)
9106 {
9107 case up:
9108
2/2
✓ Branch 0 taken 14144 times.
✓ Branch 1 taken 30 times.
14174 ny-=((dmisc1==0||dmisc1==2)?32:48);
9109 14174 break;
9110
9111 case down:
9112
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 14284 times.
14318 ny+=((dmisc1==0||dmisc1==2)?32:48);
9113
9114
4/4
✓ Branch 0 taken 10087 times.
✓ Branch 1 taken 4231 times.
✓ Branch 2 taken 10076 times.
✓ Branch 3 taken 11 times.
14318 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
9115
9116 14318 break;
9117
9118 case left:
9119
2/2
✓ Branch 0 taken 25528 times.
✓ Branch 1 taken 653 times.
26181 nx-=((dmisc1==0||dmisc1==2)?32:48);
9120 26181 break;
9121
9122 case right:
9123
2/2
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 25573 times.
26219 nx+=((dmisc1==0||dmisc1==2)?32:48);
9124
9125
4/4
✓ Branch 0 taken 19151 times.
✓ Branch 1 taken 7068 times.
✓ Branch 2 taken 18549 times.
✓ Branch 3 taken 602 times.
26219 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
9126
9127 26219 break;
9128 }
9129
9130
4/4
✓ Branch 0 taken 20429 times.
✓ Branch 1 taken 60463 times.
✓ Branch 2 taken 9001 times.
✓ Branch 3 taken 11428 times.
80892 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
9131 69464 return false;
9132
9133
2/2
✓ Branch 0 taken 865 times.
✓ Branch 1 taken 10563 times.
11428 if(d2>=left)
9134
4/4
✓ Branch 0 taken 5025 times.
✓ Branch 1 taken 5538 times.
✓ Branch 2 taken 9317 times.
✓ Branch 3 taken 1246 times.
10563 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
9135 9317 return false;
9136
9137 2111 x=nx;
9138 2111 y=ny;
9139 2111 dir=d2^1;
9140 2111 return true;
9141 80892 }
9142
9143 1024382 void eLeever::draw(BITMAP *dest)
9144 {
9145 // cs=d->cset;
9146 1024382 cs=dcset;
9147 1024382 update_enemy_frame();
9148
3/4
✓ Branch 0 taken 1024027 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1024027 times.
1024382 if(!fallclk&&!drownclk)
9149 {
9150
2/2
✓ Branch 0 taken 637088 times.
✓ Branch 1 taken 386939 times.
1024027 switch(misc)
9151 {
9152 case -1:
9153 case 0:
9154 386939 return;
9155 }
9156 637088 }
9157
9158 637443 enemy::draw(dest);
9159 1024382 }
9160
9161 998 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9162 998 {
9163 998 hashero=false;
9164 //nets+1000;
9165
1/4
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
998 if (SIZEflags != 0) init_size_flags();;
9166 998 }
9167
9168 504762 bool eWallM::animate(int32_t index)
9169 {
9170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 504762 times.
504762 if(switch_hooked) return enemy::animate(index);
9171
2/4
✓ Branch 0 taken 504762 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 504762 times.
504762 if(fallclk||drownclk)
9172 {
9173 return enemy::animate(index);
9174 }
9175
2/2
✓ Branch 0 taken 9856 times.
✓ Branch 1 taken 494906 times.
504762 if(dying)
9176 9856 return Dead(index);
9177
9178
2/2
✓ Branch 0 taken 463930 times.
✓ Branch 1 taken 30976 times.
494906 if(clk==0)
9179 {
9180 30976 removearmos(x,y,ffcactivated);
9181 30976 }
9182
9183 494906 hxofs=1000;
9184
2/2
✓ Branch 0 taken 117732 times.
✓ Branch 1 taken 377174 times.
494906 if(misc==0) //inside wall, ready to spawn?
9185 {
9186
4/4
✓ Branch 0 taken 228512 times.
✓ Branch 1 taken 148662 times.
✓ Branch 2 taken 16723 times.
✓ Branch 3 taken 211789 times.
377174 if(frame-wallm_load_clk>80 && clk>=0)
9187 {
9188 211789 int32_t wall=hero_on_wall();
9189 211789 int32_t wallm_cnt=0;
9190
9191
2/2
✓ Branch 0 taken 1670618 times.
✓ Branch 1 taken 211789 times.
1882407 for(int32_t i=0; i<guys.Count(); i++)
9192
2/2
✓ Branch 0 taken 657527 times.
✓ Branch 1 taken 1013091 times.
2683709 if(((enemy*)guys.spr(i))->type==eeWALLM)
9193 {
9194 1013091 int32_t m=((enemy*)guys.spr(i))->misc;
9195
9196
4/4
✓ Branch 0 taken 50104 times.
✓ Branch 1 taken 962987 times.
✓ Branch 2 taken 36738 times.
✓ Branch 3 taken 13366 times.
1013091 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
9197 {
9198 13366 ++wallm_cnt;
9199 13366 }
9200 1013091 }
9201
9202
2/2
✓ Branch 0 taken 210948 times.
✓ Branch 1 taken 841 times.
211789 if(wall>0)
9203 {
9204 841 --wall;
9205 841 misc=1; //emerging from the wall?
9206 841 clk2=0;
9207 841 clk3=wall^1;
9208 841 wallm_load_clk=frame;
9209
9210
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 327 times.
841 if(wall<=down)
9211 {
9212
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 423 times.
514 if(HeroDir()==left)
9213 91 dir=right;
9214 else
9215 423 dir=left;
9216 514 }
9217 else
9218 {
9219
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 261 times.
327 if(HeroDir()==up)
9220 66 dir=down;
9221 else
9222 261 dir=up;
9223 }
9224
9225
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 223 times.
✓ Branch 4 taken 104 times.
841 switch(wall)
9226 {
9227 case up:
9228 231 y=0;
9229 231 break;
9230
9231 case down:
9232 283 y=160;
9233 283 break;
9234
9235 case left:
9236 223 x=0;
9237 223 break;
9238
9239 case right:
9240 104 x=240;
9241 104 break;
9242 }
9243
9244
9245
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 91 times.
841 switch(dir)
9246 {
9247 case up:
9248 261 y=(HeroY()+48-(wallm_cnt&1)*12);
9249 261 flip=wall&1;
9250 261 break;
9251
9252 case down:
9253 66 y=(HeroY()-48+(wallm_cnt&1)*12);
9254 66 flip=((wall&1)^1)+2;
9255 66 break;
9256
9257 case left:
9258 423 x=(HeroX()+48-(wallm_cnt&1)*12);
9259 423 flip=(wall==up?2:0)+1;
9260 423 break;
9261
9262 case right:
9263 91 x=(HeroX()-48+(wallm_cnt&1)*12);
9264 91 flip=(wall==up?2:0);
9265 91 break;
9266 }
9267
9268 841 }
9269 211789 }
9270 377174 }
9271 else
9272 117732 wallm_crawl();
9273
9274 494906 return enemy::animate(index);
9275 504762 }
9276
9277 117732 void eWallM::wallm_crawl()
9278 {
9279 117732 bool w=watch;
9280 117732 hxofs=0;
9281
9282
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 116922 times.
117732 if(slide())
9283 {
9284 810 return;
9285 }
9286
9287 // if(dying || watch || (!hashero && stunclk))
9288
6/8
✓ Branch 0 taken 116922 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115593 times.
✓ Branch 3 taken 1329 times.
✓ Branch 4 taken 101047 times.
✓ Branch 5 taken 14546 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 101047 times.
116922 if(dying || (!hashero && ( stunclk || frozenclock )))
9289 {
9290 14546 return;
9291 }
9292
9293 102376 watch=false;
9294 102376 ++clk2;
9295 // Misc1: slightly different movement
9296 102376 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
9297
9298 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
9299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102376 times.
102376 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
9300
5/6
✓ Branch 0 taken 6217 times.
✓ Branch 1 taken 96159 times.
✓ Branch 2 taken 4491 times.
✓ Branch 3 taken 1726 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4491 times.
102376 if(w&&misc>=3&&misc<=5)
9301 {
9302 4491 --clk2;
9303 4491 }
9304
9305
4/4
✓ Branch 0 taken 39396 times.
✓ Branch 1 taken 52852 times.
✓ Branch 2 taken 9984 times.
✓ Branch 3 taken 144 times.
102376 switch(misc)
9306 {
9307 case 1:
9308 case 2:
9309 52852 zc_swap(dir,clk3);
9310 52852 move(step);
9311 52852 zc_swap(dir,clk3);
9312 52852 break;
9313
9314 case 3:
9315 case 4:
9316 case 5:
9317
2/2
✓ Branch 0 taken 4491 times.
✓ Branch 1 taken 34905 times.
39396 if(w)
9318 {
9319 4491 watch=w;
9320 4491 return;
9321 }
9322
9323 34905 move(step);
9324 34905 break;
9325
9326 case 6:
9327 case 7:
9328 9984 zc_swap(dir,clk3);
9329 9984 dir^=1;
9330 9984 move(step);
9331 9984 dir^=1;
9332 9984 zc_swap(dir,clk3);
9333 9984 break;
9334
9335 default:
9336 144 misc=0;
9337 144 break;
9338 }
9339
9340 97885 watch=w;
9341 117732 }
9342
9343 9 void eWallM::grabhero()
9344 {
9345 9 hashero=true;
9346 9 superman=1;
9347 9 }
9348
9349 507147 void eWallM::draw(BITMAP *dest)
9350 {
9351 507147 dummy_bool[1]=hashero;
9352 507147 update_enemy_frame();
9353
9354
4/6
✓ Branch 0 taken 377966 times.
✓ Branch 1 taken 129181 times.
✓ Branch 2 taken 377966 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 377966 times.
507147 if(misc>0 || fallclk||drownclk)
9355 {
9356 129181 masked_draw(dest,16,playing_field_offset+16,224,144);
9357 129181 }
9358
9359 // enemy::draw(dest);
9360 // tile = clk&8 ? 128:129;
9361 507147 }
9362
9363 bool eWallM::isSubmerged() const
9364 {
9365 return ( !misc );
9366 }
9367
9368 1640 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9369 1640 {
9370
1/2
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
1640 ox=x; //original x
9371
1/2
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
1640 oy=y; //original y
9372
2/2
✓ Branch 0 taken 1474 times.
✓ Branch 1 taken 166 times.
1640 if(get_qr(qr_TRAPPOSFIX))
9373 {
9374
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
✓ Branch 2 taken 166 times.
✗ Branch 3 not taken.
166 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9375 166 }
9376
9377 1640 mainguy=false;
9378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1640 times.
1640 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9379 //nets+420;
9380 1640 dummy_int[1]=0;
9381
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1640 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1640 if (SIZEflags != 0) init_size_flags();;
9382 1640 }
9383
9384 1042165 bool eTrap::animate(int32_t index)
9385 {
9386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1042165 times.
1042165 if(switch_hooked) return enemy::animate(index);
9387
2/4
✓ Branch 0 taken 1042165 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1042165 times.
1042165 if(fallclk||drownclk) return enemy::animate(index);
9388
2/2
✓ Branch 0 taken 1020511 times.
✓ Branch 1 taken 21654 times.
1042165 if(clk<0)
9389 21654 return enemy::animate(index);
9390
9391
2/2
✓ Branch 0 taken 955962 times.
✓ Branch 1 taken 64549 times.
1020511 if(clk==0)
9392 {
9393 64549 removearmos(x,y,ffcactivated);
9394 64549 }
9395
9396
2/2
✓ Branch 0 taken 319209 times.
✓ Branch 1 taken 701302 times.
1020511 if(misc==0) // waiting
9397 {
9398 701302 ox = x;
9399 701302 oy = y;
9400 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9401 701302 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
9402
9403
4/4
✓ Branch 0 taken 241777 times.
✓ Branch 1 taken 459525 times.
✓ Branch 2 taken 133516 times.
✓ Branch 3 taken 108261 times.
701302 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
9404 {
9405 108261 dir=down;
9406 108261 }
9407
4/4
✓ Branch 0 taken 393308 times.
✓ Branch 1 taken 199733 times.
✓ Branch 2 taken 133516 times.
✓ Branch 3 taken 259792 times.
593041 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
9408 {
9409 259792 dir=right;
9410 259792 }
9411
4/4
✓ Branch 0 taken 212039 times.
✓ Branch 1 taken 121210 times.
✓ Branch 2 taken 133516 times.
✓ Branch 3 taken 78523 times.
333249 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
9412 {
9413 78523 dir=up;
9414 78523 }
9415 else
9416 {
9417 254726 dir=left;
9418 }
9419
9420 701302 int32_t d2=lined_up(15,true);
9421
9422
4/4
✓ Branch 0 taken 268741 times.
✓ Branch 1 taken 432561 times.
✓ Branch 2 taken 1107234 times.
✓ Branch 3 taken 405932 times.
1095295 if(((d2<left || d2 > right) && (dmisc1==1)) ||
9423
2/2
✓ Branch 0 taken 232564 times.
✓ Branch 1 taken 173368 times.
405932 ((d2>down) && (dmisc1==2)) ||
9424
2/2
✓ Branch 0 taken 187069 times.
✓ Branch 1 taken 81901 times.
173368 ((d2>right) && (!dmisc1)) ||
9425
2/2
✓ Branch 0 taken 393993 times.
✓ Branch 1 taken 125023 times.
268970 ((d2<l_up) && (dmisc1==4)) ||
9426
3/4
✓ Branch 0 taken 393993 times.
✓ Branch 1 taken 268970 times.
✓ Branch 2 taken 393993 times.
✗ Branch 3 not taken.
125023 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
9427
3/4
✓ Branch 0 taken 393993 times.
✓ Branch 1 taken 125023 times.
✓ Branch 2 taken 393993 times.
✗ Branch 3 not taken.
268970 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
9428 {
9429 2521777 d2=-1;
9430 2521777 }
9431
9432
4/4
✓ Branch 0 taken 20708 times.
✓ Branch 1 taken 411624 times.
✓ Branch 2 taken 18593 times.
✓ Branch 3 taken 2115 times.
432332 if(d2!=-1 && trapmove(d2))
9433 {
9434 2115 dir=d2;
9435 2115 misc=1;
9436 2115 clk2=(dir==down)?3:0;
9437 2115 }
9438 432332 }
9439
9440
2/2
✓ Branch 0 taken 662006 times.
✓ Branch 1 taken 89535 times.
751541 if(misc==1) // charging
9441 {
9442 89535 clk2=(clk2+1)&3;
9443 89535 step=(clk2==3)?1:2;
9444
9445
4/4
✓ Branch 0 taken 88731 times.
✓ Branch 1 taken 804 times.
✓ Branch 2 taken 1105 times.
✓ Branch 3 taken 87626 times.
89535 if(!trapmove(dir) || clip())
9446 {
9447 1909 misc=2;
9448
9449
1/2
✓ Branch 0 taken 1909 times.
✗ Branch 1 not taken.
1909 if(dir<l_up)
9450 {
9451 1909 dir=dir^1;
9452 1909 }
9453 else
9454 {
9455 dir=dir^3;
9456 }
9457 1909 }
9458 else
9459 {
9460 87626 sprite::move(step);
9461 }
9462 89535 }
9463
9464
2/2
✓ Branch 0 taken 517843 times.
✓ Branch 1 taken 233698 times.
751541 if(misc==2) // retreating
9465 {
9466 233698 step=(++clk2&1)?1:0;
9467
9468
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 39011 times.
✓ Branch 2 taken 80947 times.
✓ Branch 3 taken 29129 times.
✓ Branch 4 taken 84611 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
233698 switch(dir)
9469 {
9470 case up:
9471
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 38739 times.
39011 if(int32_t(y)<=oy) goto trap_rest;
9472 38739 else sprite::move(step);
9473
9474 38739 break;
9475
9476 case left:
9477
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 80555 times.
80947 if(int32_t(x)<=ox) goto trap_rest;
9478 80555 else sprite::move(step);
9479
9480 80555 break;
9481
9482 case down:
9483
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 28905 times.
29129 if(int32_t(y)>=oy) goto trap_rest;
9484 28905 else sprite::move(step);
9485
9486 28905 break;
9487
9488 case right:
9489
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 84176 times.
84611 if(int32_t(x)>=ox) goto trap_rest;
9490 84176 else sprite::move(step);
9491
9492 84176 break;
9493
9494 case l_up:
9495 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
9496 else sprite::move(step);
9497
9498 break;
9499
9500 case r_up:
9501 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
9502 else sprite::move(step);
9503
9504 break;
9505
9506 case l_down:
9507 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
9508 else sprite::move(step);
9509
9510 break;
9511
9512 case r_down:
9513 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
9514 else sprite::move(step);
9515
9516 break;
9517 trap_rest:
9518 {
9519 1323 x=ox;
9520 1323 y=oy;
9521 1323 misc=0;
9522 }
9523 1323 }
9524 233698 }
9525
9526 751541 return enemy::animate(index);
9527 773195 }
9528
9529 110243 bool eTrap::trapmove(int32_t ndir)
9530 {
9531
2/2
✓ Branch 0 taken 80479 times.
✓ Branch 1 taken 29764 times.
110243 if(get_qr(qr_MEANTRAPS))
9532 {
9533 80479 mapscr* scr = get_scr(screen_spawned);
9534
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 79139 times.
80479 if(scr->flags2&fFLOATTRAPS)
9535 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9536
9537 79139 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9538 }
9539
9540
6/6
✓ Branch 0 taken 14672 times.
✓ Branch 1 taken 15092 times.
✓ Branch 2 taken 7198 times.
✓ Branch 3 taken 7474 times.
✓ Branch 4 taken 2468 times.
✓ Branch 5 taken 4730 times.
29764 if(oy==80 && !(ndir==left || ndir == right))
9541 4730 return false;
9542
9543
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25034 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25034 if(ox==128 && !(ndir==up || ndir==down))
9544 return false;
9545
9546
3/4
✓ Branch 0 taken 7496 times.
✓ Branch 1 taken 17538 times.
✓ Branch 2 taken 7496 times.
✗ Branch 3 not taken.
25034 if(oy<80 && ndir==up)
9547 return false;
9548
9549
3/4
✓ Branch 0 taken 7596 times.
✓ Branch 1 taken 17438 times.
✓ Branch 2 taken 7596 times.
✗ Branch 3 not taken.
25034 if(oy>80 && ndir==down)
9550 return false;
9551
9552
4/4
✓ Branch 0 taken 14455 times.
✓ Branch 1 taken 10579 times.
✓ Branch 2 taken 9733 times.
✓ Branch 3 taken 4722 times.
25034 if(ox<128 && ndir==left)
9553 4722 return false;
9554
9555
4/4
✓ Branch 0 taken 10579 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 9866 times.
✓ Branch 3 taken 713 times.
20312 if(ox>128 && ndir==right)
9556 713 return false;
9557
9558
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 4067 times.
✓ Branch 3 taken 5666 times.
✓ Branch 4 taken 4067 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy<80 && ndir==l_up)
9559 return false;
9560
9561
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 3911 times.
✓ Branch 3 taken 5822 times.
✓ Branch 4 taken 3911 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy>80 && ndir==l_down)
9562 return false;
9563
9564
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3429 times.
✓ Branch 3 taken 6437 times.
✓ Branch 4 taken 3429 times.
✗ Branch 5 not taken.
19599 if(ox>128 && oy<80 && ndir==r_up)
9565 return false;
9566
9567
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 6181 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3685 times.
19599 if(ox>128 && oy>80 && ndir==r_down)
9568 return false;
9569
9570 19599 return true;
9571 110243 }
9572
9573 88731 bool eTrap::clip()
9574 {
9575
2/2
✓ Branch 0 taken 43022 times.
✓ Branch 1 taken 45709 times.
88731 if(get_qr(qr_MEANPLACEDTRAPS))
9576 {
9577
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
✓ Branch 2 taken 8656 times.
✓ Branch 3 taken 16039 times.
✓ Branch 4 taken 15222 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
45709 switch(dir)
9578 {
9579 case up:
9580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
5792 if(y<=0) return true;
9581
9582 5792 break;
9583
9584 case down:
9585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8656 times.
8656 if(y>=world_h-16) return true;
9586
9587 8656 break;
9588
9589 case left:
9590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16039 times.
16039 if(x<=0) return true;
9591
9592 16039 break;
9593
9594 case right:
9595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15222 times.
15222 if(x>=world_w-16) return true;
9596
9597 15222 break;
9598
9599 case l_up:
9600 if(y<=0||x<=0) return true;
9601
9602 break;
9603
9604 case l_down:
9605 if(y>=world_h-16||x<=0) return true;
9606
9607 break;
9608
9609 case r_up:
9610 if(y<=0||x>=world_w-16) return true;
9611
9612 break;
9613
9614 case r_down:
9615 if(y>=world_h-16||x>=world_w-16) return true;
9616
9617 break;
9618 }
9619
9620 45709 return false;
9621 }
9622 else
9623 {
9624
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 4882 times.
✓ Branch 2 taken 5449 times.
✓ Branch 3 taken 16755 times.
✓ Branch 4 taken 15936 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
43022 switch(dir)
9625 {
9626 case up:
9627
4/4
✓ Branch 0 taken 4828 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 4641 times.
✓ Branch 3 taken 187 times.
4882 if(oy>80 && y<=86) return true;
9628
9629 4695 break;
9630
9631 case down:
9632
4/4
✓ Branch 0 taken 5368 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 5172 times.
✓ Branch 3 taken 196 times.
5449 if(oy<80 && y>=80) return true;
9633
9634 5253 break;
9635
9636 case left:
9637
4/4
✓ Branch 0 taken 16665 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 16286 times.
✓ Branch 3 taken 379 times.
16755 if(ox>128 && x<=124) return true;
9638
9639 16376 break;
9640
9641 case right:
9642
4/4
✓ Branch 0 taken 15855 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 15512 times.
✓ Branch 3 taken 343 times.
15936 if(ox<120 && x>=116) return true;
9643
9644 15593 break;
9645
9646 case l_up:
9647 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
9648
9649 break;
9650
9651 case l_down:
9652 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
9653
9654 break;
9655
9656 case r_up:
9657 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
9658
9659 break;
9660
9661 case r_down:
9662 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
9663
9664 break;
9665 }
9666
9667 41917 return false;
9668 }
9669 88731 }
9670
9671 1061079 void eTrap::draw(BITMAP *dest)
9672 {
9673 1061079 update_enemy_frame();
9674 1061079 enemy::draw(dest);
9675 1061079 }
9676
9677 5705 int32_t eTrap::takehit(weapon*,weapon*)
9678 {
9679 5705 return 0;
9680 }
9681
9682 832 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9683 832 {
9684 832 lasthit=-1;
9685 832 lasthitclk=0;
9686 832 mainguy=false;
9687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9688
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 step=2;
9689
3/6
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 399 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
9690 {
9691
2/4
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399 times.
✗ Branch 3 not taken.
399 dir=(x<=112)?right:left;
9692 399 }
9693 else
9694 {
9695
2/4
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 433 times.
✗ Branch 3 not taken.
433 dir=(y<=72)?down:up;
9696 }
9697
9698
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 72 times.
832 if(get_qr(qr_TRAPPOSFIX))
9699 {
9700
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
72 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9701 72 }
9702
9703 //nets+((id==eTRAP_LR)?540:520);
9704 832 dummy_int[1]=0;
9705
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
832 if (SIZEflags != 0) init_size_flags();;
9706 832 }
9707
9708 346559 bool eTrap2::animate(int32_t index)
9709 {
9710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 346559 times.
346559 if(switch_hooked) return enemy::animate(index);
9711
2/4
✓ Branch 0 taken 346559 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 346559 times.
346559 if(fallclk||drownclk) return enemy::animate(index);
9712
2/2
✓ Branch 0 taken 335533 times.
✓ Branch 1 taken 11026 times.
346559 if(clk<0)
9713 11026 return enemy::animate(index);
9714
9715
2/2
✓ Branch 0 taken 21385 times.
✓ Branch 1 taken 314148 times.
335533 if(clk==0)
9716 {
9717 21385 removearmos(x,y,ffcactivated);
9718 21385 }
9719
9720
2/2
✓ Branch 0 taken 211207 times.
✓ Branch 1 taken 124326 times.
335533 if(!get_qr(qr_PHANTOMPLACEDTRAPS))
9721 {
9722
2/2
✓ Branch 0 taken 11074 times.
✓ Branch 1 taken 113252 times.
124326 if(lasthitclk>0)
9723 {
9724 11074 --lasthitclk;
9725 11074 }
9726 else
9727 {
9728 113252 lasthit=-1;
9729 }
9730
9731 124326 bool hitenemy=false;
9732
9733
2/2
✓ Branch 0 taken 864860 times.
✓ Branch 1 taken 124326 times.
989186 for(int32_t j=0; j<guys.Count(); j++)
9734 {
9735
4/4
✓ Branch 0 taken 740534 times.
✓ Branch 1 taken 124326 times.
✓ Branch 2 taken 10183 times.
✓ Branch 3 taken 730351 times.
864860 if((j!=index) && (lasthit!=j))
9736 {
9737
2/2
✓ Branch 0 taken 726682 times.
✓ Branch 1 taken 3669 times.
730351 if(hit(guys.spr(j)))
9738 {
9739 3669 lasthit=j;
9740 3669 lasthitclk=10;
9741 3669 hitenemy=true;
9742 3669 guys.spr(j)->lasthit=index;
9743 3669 guys.spr(j)->lasthitclk=10;
9744 // guys.spr(j)->dir=guys.spr(j)->dir^1;
9745 3669 }
9746 730351 }
9747 864860 }
9748
9749
5/6
✓ Branch 0 taken 121171 times.
✓ Branch 1 taken 3155 times.
✓ Branch 2 taken 121171 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2831 times.
✓ Branch 5 taken 118340 times.
124326 if(!trapmove(dir) || clip() || hitenemy)
9750 {
9751
3/4
✓ Branch 0 taken 2831 times.
✓ Branch 1 taken 3155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2831 times.
5986 if(!trapmove(dir) || clip())
9752 {
9753 3155 lasthit=-1;
9754 3155 lasthitclk=0;
9755 3155 }
9756
9757
2/2
✓ Branch 0 taken 5624 times.
✓ Branch 1 taken 362 times.
5986 if(get_qr(qr_MORESOUNDS))
9758 362 sfx(WAV_ZN1TAP,pan(x));
9759
9760 5986 dir=dir^1;
9761 5986 }
9762
9763 124326 sprite::move(step);
9764 124326 }
9765 else
9766 {
9767
3/4
✓ Branch 0 taken 204288 times.
✓ Branch 1 taken 6919 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 204288 times.
211207 if(!trapmove(dir) || clip())
9768 {
9769
2/2
✓ Branch 0 taken 5398 times.
✓ Branch 1 taken 1521 times.
6919 if(get_qr(qr_MORESOUNDS))
9770 1521 sfx(WAV_ZN1TAP,pan(x));
9771
9772 6919 dir=dir^1;
9773 6919 }
9774
9775 211207 sprite::move(step);
9776 }
9777
9778 335533 return enemy::animate(index);
9779 346559 }
9780
9781 341519 bool eTrap2::trapmove(int32_t ndir)
9782 {
9783 341519 mapscr* scr = get_scr(screen_spawned);
9784
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 339641 times.
341519 if(scr->flags2&fFLOATTRAPS)
9785 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9786
9787 339641 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9788 341519 }
9789
9790 328290 bool eTrap2::clip()
9791 {
9792
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 88320 times.
✓ Branch 2 taken 89029 times.
✓ Branch 3 taken 75153 times.
✓ Branch 4 taken 75788 times.
328290 switch(dir)
9793 {
9794 case up:
9795
1/2
✓ Branch 0 taken 88320 times.
✗ Branch 1 not taken.
88320 if(y<=0) return true;
9796
9797 88320 break;
9798
9799 case down:
9800
1/2
✓ Branch 0 taken 89029 times.
✗ Branch 1 not taken.
89029 if(y>=world_h-16) return true;
9801
9802 89029 break;
9803
9804 case left:
9805
1/2
✓ Branch 0 taken 75153 times.
✗ Branch 1 not taken.
75153 if(x<=0) return true;
9806
9807 75153 break;
9808
9809 case right:
9810
1/2
✓ Branch 0 taken 75788 times.
✗ Branch 1 not taken.
75788 if(x>=world_w-16) return true;
9811
9812 75788 break;
9813 }
9814
9815 328290 return false;
9816 328290 }
9817
9818 350933 void eTrap2::draw(BITMAP *dest)
9819 {
9820 350933 update_enemy_frame();
9821 350933 enemy::draw(dest);
9822 350933 }
9823
9824 3169 int32_t eTrap2::takehit(weapon*,weapon*)
9825 {
9826 3169 return 0;
9827 }
9828
9829 354 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9830 354 {
9831 //do not show "enemy appering" anim -DD
9832 354 clk=0;
9833 354 mainguy=false;
9834 354 clk2=-14;
9835 //Enemy Editor Size Tab
9836
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 init_size_flags();
9837 //nets+1640;
9838 354 }
9839
9840 354 void eRock::init_size_flags()
9841 {
9842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
9843 354 else hxofs = -2;
9844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
9845 354 else hyofs = -2;
9846
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
9847 354 else hit_width = 20;
9848
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
9849 354 else hit_height = 20;
9850
9851
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9852
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
9853
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
9854
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
9855
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
9856 {
9857 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9858 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
9859 }
9860
9861
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
9862 354 }
9863
9864 121997 bool eRock::animate(int32_t index)
9865 {
9866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(switch_hooked) return enemy::animate(index);
9867
2/4
✓ Branch 0 taken 121997 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 121997 times.
121997 if(fallclk||drownclk) return enemy::animate(index);
9868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(dying)
9869 return Dead(index);
9870
9871
2/2
✓ Branch 0 taken 113621 times.
✓ Branch 1 taken 8376 times.
121997 if(clk==0)
9872 {
9873 8376 removearmos(x,y,ffcactivated);
9874 8376 }
9875
9876
2/2
✓ Branch 0 taken 121300 times.
✓ Branch 1 taken 697 times.
121997 if(++clk2==0) // start it
9877 {
9878 697 x=zc_oldrand()&0xF0;
9879 697 y=0;
9880 697 clk3=0;
9881 697 clk2=zc_oldrand()&15;
9882 697 }
9883
9884
2/2
✓ Branch 0 taken 22820 times.
✓ Branch 1 taken 99177 times.
121997 if(clk2>16) // move it
9885 {
9886
2/2
✓ Branch 0 taken 95747 times.
✓ Branch 1 taken 3430 times.
99177 if(clk3<=0) // start bounce
9887 {
9888 3430 dir=zc_oldrand()&1;
9889
9890
2/2
✓ Branch 0 taken 3063 times.
✓ Branch 1 taken 367 times.
3430 if(x<32) dir=1;
9891
9892
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 297 times.
3430 if(x>208) dir=0;
9893 3430 }
9894
9895
2/2
✓ Branch 0 taken 95993 times.
✓ Branch 1 taken 3184 times.
99177 if(clk3<13+16)
9896 {
9897 95993 x += dir ? 1 : -1; //right, left
9898 95993 dummy_int[1]=dir;
9899
9900
2/2
✓ Branch 0 taken 6852 times.
✓ Branch 1 taken 89141 times.
95993 if(clk3<2)
9901 {
9902 6852 y-=2; //up
9903 6852 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9904 6852 }
9905
2/2
✓ Branch 0 taken 10208 times.
✓ Branch 1 taken 78933 times.
89141 else if(clk3<5)
9906 {
9907 10208 y--; //up
9908 10208 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9909 10208 }
9910
2/2
✓ Branch 0 taken 10135 times.
✓ Branch 1 taken 68798 times.
78933 else if(clk3<8)
9911 {
9912 10135 dummy_int[2]=(dummy_int[1]==1)?right:left;
9913 10135 }
9914
2/2
✓ Branch 0 taken 10058 times.
✓ Branch 1 taken 58740 times.
68798 else if(clk3<11)
9915 {
9916 10058 y++; //down
9917 10058 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9918 10058 }
9919 else
9920 {
9921 58740 y+=2; //down
9922 58740 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9923 }
9924
9925 95993 ++clk3;
9926 95993 }
9927
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 423 times.
3184 else if(y<world_h)
9928 2761 clk3=0; // next bounce
9929 else
9930 423 clk2 = -(zc_oldrand()&63); // back to top
9931 99177 }
9932
9933 121997 return enemy::animate(index);
9934 121997 }
9935
9936 51441 void eRock::drawshadow(BITMAP *dest, bool translucent)
9937 {
9938
2/2
✓ Branch 0 taken 7191 times.
✓ Branch 1 taken 44250 times.
51441 if(clk2>=0)
9939 {
9940 44250 int32_t tempy=yofs;
9941 44250 flip = 0;
9942 44250 int32_t fdiv = frate/4;
9943
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
9944
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t f2=get_qr(qr_NEWENEMYTILES)?
9945 44250 efrate:((clk>=(frate>>1))?1:0);
9946 44250 shadowtile = wpnsbuf[spr_shadow].tile+f2;
9947
9948 44250 yofs+=8;
9949
6/6
✓ Branch 0 taken 20474 times.
✓ Branch 1 taken 23776 times.
✓ Branch 2 taken 38962 times.
✓ Branch 3 taken 5288 times.
✓ Branch 4 taken 19073 times.
✓ Branch 5 taken 19889 times.
44250 yofs+=zc_max(0,zc_min(29-clk3,clk3));
9950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44250 times.
44250 if(!shadow_overpit(this))
9951 44250 sprite::drawshadow(dest, translucent);
9952 44250 yofs=tempy;
9953 44250 }
9954 51441 }
9955
9956 122078 void eRock::draw(BITMAP *dest)
9957 {
9958
4/6
✓ Branch 0 taken 17035 times.
✓ Branch 1 taken 105043 times.
✓ Branch 2 taken 17035 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 17035 times.
122078 if(clk2>=0 || fallclk||drownclk)
9959 {
9960 105043 int32_t tempdir=dir;
9961 105043 dir=dummy_int[2];
9962 105043 update_enemy_frame();
9963 105043 enemy::draw(dest);
9964 105043 dir=tempdir;
9965 105043 }
9966 122078 }
9967
9968 1014 int32_t eRock::takehit(weapon*,weapon*)
9969 {
9970 1014 return 0;
9971 }
9972
9973 30 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9974 30 {
9975 30 clk=0;
9976 30 mainguy=false;
9977 30 clk2=-14;
9978
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 init_size_flags();
9979 //nets+1680;
9980 30 }
9981
9982 4440 bool eBoulder::animate(int32_t index)
9983 {
9984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
9985
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
9986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
9987 return Dead(index);
9988
9989
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
9990 {
9991 290 removearmos(x,y,ffcactivated);
9992 290 }
9993
9994 zfix *vert;
9995
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & move_use_fake_z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y;
9996
9997
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
9998 {
9999 32 x=zc_oldrand()&0xF0;
10000 32 y=-32;
10001 32 clk3=0;
10002 32 clk2=zc_oldrand()&15;
10003 32 }
10004
10005
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
10006 {
10007
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
10008 {
10009 131 dir=zc_oldrand()&1;
10010
10011
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
10012
10013
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
10014 131 }
10015
10016
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
10017 {
10018 3487 x += dir ? 1 : -1; //right, left
10019 3487 dummy_int[1]=dir;
10020
10021
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
10022 {
10023 261 y-=2; //up
10024 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10025 261 }
10026
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
10027 {
10028 382 y--; //up
10029 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10030 382 }
10031
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
10032 {
10033 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
10034 376 }
10035
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
10036 {
10037 367 y++; //down
10038 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10039 367 }
10040 else
10041 {
10042 2101 y+=2; //down
10043 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10044 }
10045
10046 3487 ++clk3;
10047 3487 }
10048
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
10049 101 clk3=0; // next bounce
10050 else
10051 10 clk2 = -(zc_oldrand()&63); // back to top
10052 3598 }
10053
10054 4440 return enemy::animate(index);
10055 4440 }
10056
10057 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
10058 {
10059
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(clk2>=0)
10060 {
10061 3868 int32_t tempy=yofs;
10062 3868 flip = 0;
10063 3868 int32_t f2=((clk<<2)/frate)<<1;
10064 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10065
6/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1618 times.
✓ Branch 5 taken 1738 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10066
10067 3868 yofs+=8;
10068 3868 xofs-=8;
10069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10070 3868 sprite::drawshadow(dest, translucent);
10071 3868 xofs+=16;
10072 3868 ++shadowtile;
10073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10074 3868 sprite::drawshadow(dest, translucent);
10075 3868 yofs+=16;
10076 3868 shadowtile+=20;
10077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10078 3868 sprite::drawshadow(dest, translucent);
10079 3868 xofs-=16;
10080 3868 --shadowtile;
10081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10082 3868 sprite::drawshadow(dest, translucent);
10083 3868 xofs+=8;
10084 3868 yofs=tempy;
10085 3868 }
10086 4440 }
10087
10088 4440 void eBoulder::draw(BITMAP *dest)
10089 {
10090
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
10091 {
10092 3868 int32_t tempdir=dir;
10093 3868 dir=dummy_int[2];
10094 3868 update_enemy_frame();
10095 3868 dir=tempdir;
10096 3868 xofs-=8;
10097 3868 yofs-=8;
10098 3868 drawblock(dest,15);
10099 3868 xofs+=8;
10100 3868 yofs+=8;
10101 // enemy::draw(dest);
10102 3868 }
10103 4440 }
10104
10105 30 void eBoulder::init_size_flags()
10106 {
10107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
10108 30 else hxofs = -10;
10109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
10110 30 else hyofs = -10;
10111
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10112 30 else hit_width = 36;
10113
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
10114 30 else hit_height = 36;
10115
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
10116 30 else hzsz = 16; //can't be jumped
10117
10118
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10119
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
10120
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10121
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
10122
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
10123 {
10124 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10125 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
10126 }
10127
10128
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
10129 30 }
10130
10131 int32_t eBoulder::takehit(weapon*,weapon*)
10132 {
10133 return 0;
10134 }
10135
10136 4429 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
10137
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 3898 times.
4429 minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk)
10138 4429 {
10139 /* fixing
10140 hp=1;
10141 */
10142 4429 mainguy=false;
10143
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4422 times.
4429 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10144 4429 hclk=clk; // the "no fire" range
10145 4429 clk=0;
10146 4429 clk3=96;
10147 4429 timer=0;
10148
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 4415 times.
4429 if(o_tile==0)
10149 {
10150 4415 superman=1;
10151 4415 hxofs=1000;
10152 4415 }
10153
1/4
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4429 if (SIZEflags != 0) init_size_flags();;
10154 4429 }
10155
10156 2504746 bool eProjectile::animate(int32_t index)
10157 {
10158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2504746 times.
2504746 if(switch_hooked) return enemy::animate(index);
10159
2/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2504746 times.
2504746 if(fallclk||drownclk) return enemy::animate(index);
10160
2/2
✓ Branch 0 taken 2492420 times.
✓ Branch 1 taken 12326 times.
2504746 if(clk==0)
10161 {
10162 12326 removearmos(x,y,ffcactivated);
10163 12326 }
10164
10165 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10166 2504746 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10167
10168
4/4
✓ Branch 0 taken 835608 times.
✓ Branch 1 taken 1669138 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 403631 times.
2504746 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10169 {
10170 403631 dir=down;
10171 403631 }
10172
4/4
✓ Branch 0 taken 1348897 times.
✓ Branch 1 taken 752218 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 916920 times.
2101115 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10173 {
10174 916920 dir=right;
10175 916920 }
10176
4/4
✓ Branch 0 taken 790877 times.
✓ Branch 1 taken 393318 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 358900 times.
1184195 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
10177 {
10178 358900 dir=up;
10179 358900 }
10180 else
10181 {
10182 825295 dir=left;
10183 }
10184
10185
3/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1306267 times.
✓ Branch 3 taken 1198479 times.
2504746 if(!stunclk && ++clk3>80)
10186 {
10187
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 1197433 times.
1198479 if(dmisc1==9) // Breath type
10188 {
10189
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 563 times.
1046 if(timer==0)
10190 {
10191 563 unsigned r=zc_oldrand();
10192
10193
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 557 times.
563 if(!(r&63))
10194 {
10195 6 timer=zc_oldrand()%50+50;
10196 6 }
10197 563 }
10198
10199
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 489 times.
1046 if(timer>0)
10200 {
10201
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 119 times.
489 if(timer%4==0)
10202 {
10203 119 FireBreath(false);
10204 119 }
10205
10206
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 6 times.
489 if(--timer==0)
10207 {
10208 6 clk3=0;
10209 6 }
10210 489 }
10211 1046 }
10212
10213 else // Not breath type
10214 {
10215 1197433 unsigned r=zc_oldrand();
10216
10217
4/4
✓ Branch 0 taken 18808 times.
✓ Branch 1 taken 1178625 times.
✓ Branch 2 taken 1266 times.
✓ Branch 3 taken 17542 times.
1197433 if(!(r&63) && !HeroInRange(minRange))
10218 {
10219 17542 FireWeapon();
10220
10221
4/4
✓ Branch 0 taken 15040 times.
✓ Branch 1 taken 2502 times.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 66 times.
17794 if(get_qr(qr_BROKENSTATUES)==0 &&
10222
3/4
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 14788 times.
✓ Branch 2 taken 252 times.
✗ Branch 3 not taken.
15040 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
10223 {
10224
2/2
✓ Branch 0 taken 13945 times.
✓ Branch 1 taken 909 times.
14854 if(!((r>>7)&15))
10225 {
10226 909 x-=4;
10227 909 FireWeapon();
10228 909 x+=4;
10229 909 }
10230 14854 }
10231
10232 17542 clk3=0;
10233 17542 }
10234 }
10235 1198479 }
10236
10237 2504746 return enemy::animate(index);
10238 2504746 }
10239
10240 2520335 void eProjectile::draw(BITMAP *dest)
10241 {
10242 2520335 update_enemy_frame();
10243 2520335 enemy::draw(dest);
10244 2520335 }
10245
10246 533 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10247 533 {
10248 533 hxofs=1000;
10249 533 }
10250
10251 249811 void eTrigger::draw(BITMAP *dest)
10252 {
10253 249811 update_enemy_frame();
10254 249811 enemy::draw(dest);
10255 249811 }
10256
10257 void eTrigger::death_sfx()
10258 {
10259 //silent death
10260 }
10261
10262 5 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10263 5 {
10264 5 o_tile+=wpnsbuf[iwNPCs].tile;
10265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10266 5 SIZEflags = d->SIZEflags;
10267
1/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if (SIZEflags != 0) init_size_flags();;
10268 5 }
10269
10270 75 bool eNPC::animate(int32_t index)
10271 {
10272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(switch_hooked) return enemy::animate(index);
10273
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 5 times.
75 if(dying)
10274 70 return Dead(index);
10275
10276
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(clk==0)
10277 {
10278 removearmos(x,y,ffcactivated);
10279 }
10280
10281
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 switch(dmisc2)
10282 {
10283 case 0:
10284 {
10285 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10286 5 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10287
10288
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10289 {
10290 dir=down;
10291 }
10292
10293
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10294 {
10295 5 dir=right;
10296 5 }
10297 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
10298 {
10299 dir=up;
10300 }
10301 else
10302 {
10303 dir=left;
10304 }
10305 }
10306 5 break;
10307
10308 case 1:
10309 halting_walk(rate, homing, 0, hrate, 48);
10310
10311 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
10312 {
10313 newdir(rate, homing, 0);
10314 clk2=48;
10315 ++misc;
10316 }
10317
10318 if(clk2==0)
10319 misc=0;
10320
10321 break;
10322 }
10323
10324 5 return enemy::animate(index);
10325 75 }
10326
10327 75 void eNPC::draw(BITMAP *dest)
10328 {
10329 75 update_enemy_frame();
10330 75 enemy::draw(dest);
10331 75 }
10332
10333 int32_t eNPC::takehit(weapon*,weapon*)
10334 {
10335 return 0;
10336 }
10337
10338 94 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10339 94 {
10340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
10341 {
10342 94 o_tile=clk;
10343 94 cs=id>>12;
10344 94 }
10345
10346 94 id=id&0xFFF;
10347 94 clk=0;
10348
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
10349 94 mainguy=false;
10350 94 SIZEflags = d->SIZEflags;
10351
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if (SIZEflags != 0) init_size_flags();;
10352 94 }
10353
10354 81 void eSpinTile::facehero()
10355 {
10356
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
10357 {
10358
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
10359 1 dir = up;
10360 else
10361 dir = down;
10362 1 }
10363 else
10364 {
10365 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10366 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10367
10368
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
10369 {
10370 12 dir=l_down;
10371 12 }
10372
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
10373 {
10374 1 dir=down;
10375 1 }
10376
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
10377 {
10378 12 dir=r_down;
10379 12 }
10380
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
10381 {
10382 6 dir=right;
10383 6 }
10384
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
10385 {
10386 17 dir=r_up;
10387 17 }
10388
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
10389 {
10390 8 dir=up;
10391 8 }
10392
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
10393 {
10394 6 dir=l_up;
10395 6 }
10396 else
10397 {
10398 18 dir=left;
10399 }
10400 }
10401 81 }
10402
10403
10404 15539 bool eSpinTile::animate(int32_t index)
10405 {
10406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
10407
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
10408
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
10409 {
10410 1152 return Dead(index);
10411 }
10412
10413
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
10414 {
10415 1241 removearmos(x,y,ffcactivated);
10416 1241 }
10417
10418 14387 ++misc;
10419
10420
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
10421 {
10422 81 facehero();
10423 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10424 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
10425 81 angular=true;
10426 81 angle=ddir;
10427 81 step=zslongToFix(dstep*100);
10428 81 }
10429
10430
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
10431 52 kickbucket();
10432
10433 14387 sprite::move(step);
10434 14387 return enemy::animate(index);
10435 15539 }
10436
10437 15457 void eSpinTile::draw(BITMAP *dest)
10438 {
10439 15457 update_enemy_frame();
10440 15457 y-=(misc>>4);
10441 15457 yofs+=2;
10442 15457 enemy::draw(dest);
10443 15457 yofs-=2;
10444 15457 y+=(misc>>4);
10445 15457 }
10446
10447 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
10448 {
10449 15457 flip = 0;
10450 15457 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
10451 15457 yofs+=4;
10452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15457 times.
15457 if(!shadow_overpit(this))
10453 15457 enemy::drawshadow(dest, translucent);
10454 15457 yofs-=4;
10455 15457 }
10456
10457 2797 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
10458 2797 {
10459 //these are here to bypass compiler warnings about unused arguments
10460 2797 Clk=Clk;
10461 2797 mainguy=false;
10462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2797 times.
2797 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10463
1/4
✓ Branch 0 taken 2797 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2797 if (SIZEflags != 0) init_size_flags();;
10464 2797 }
10465
10466 628398 void eZora::facehero()
10467 {
10468
2/2
✓ Branch 0 taken 10785 times.
✓ Branch 1 taken 617613 times.
628398 if(Hero.x-x==0)
10469 {
10470 10785 dir=(Hero.y+8<y)?up:down;
10471 10785 }
10472 else
10473 {
10474 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10475 617613 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10476
10477
4/4
✓ Branch 0 taken 125430 times.
✓ Branch 1 taken 492183 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 78554 times.
617613 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
10478 {
10479 78554 dir=l_down;
10480 78554 }
10481
4/4
✓ Branch 0 taken 91951 times.
✓ Branch 1 taken 447108 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 45075 times.
539059 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
10482 {
10483 45075 dir=down;
10484 45075 }
10485
4/4
✓ Branch 0 taken 121090 times.
✓ Branch 1 taken 372894 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 74214 times.
493984 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
10486 {
10487 74214 dir=r_down;
10488 74214 }
10489
4/4
✓ Branch 0 taken 162238 times.
✓ Branch 1 taken 257532 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 115362 times.
419770 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
10490 {
10491 115362 dir=right;
10492 115362 }
10493
4/4
✓ Branch 0 taken 127279 times.
✓ Branch 1 taken 177129 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 80403 times.
304408 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
10494 {
10495 80403 dir=r_up;
10496 80403 }
10497
4/4
✓ Branch 0 taken 88819 times.
✓ Branch 1 taken 135186 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 41943 times.
224005 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
10498 {
10499 41943 dir=up;
10500 41943 }
10501
4/4
✓ Branch 0 taken 121548 times.
✓ Branch 1 taken 60514 times.
✓ Branch 2 taken 74672 times.
✓ Branch 3 taken 46876 times.
182062 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
10502 {
10503 74672 dir=l_up;
10504 74672 }
10505 else
10506 {
10507 107390 dir=left;
10508 }
10509 }
10510 628398 }
10511
10512 857137 bool eZora::animate(int32_t index)
10513 {
10514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 857137 times.
857137 if(switch_hooked) return enemy::animate(index);
10515
2/2
✓ Branch 0 taken 2854 times.
✓ Branch 1 taken 854283 times.
857137 if(dying)
10516 2854 return Dead(index);
10517
10518
2/2
✓ Branch 0 taken 848537 times.
✓ Branch 1 taken 5746 times.
854283 if(clk==0)
10519 {
10520 5746 removearmos(x,y,ffcactivated);
10521 5746 }
10522
10523
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 854248 times.
854283 if(watch)
10524 {
10525 35 clock_zoras.push_back({screen_spawned, id});
10526 35 return true;
10527 }
10528
10529
2/2
✓ Branch 0 taken 225850 times.
✓ Branch 1 taken 628398 times.
854248 if(get_qr(qr_NEWENEMYTILES))
10530 {
10531 628398 facehero();
10532 628398 }
10533
10534
6/6
✓ Branch 0 taken 5232 times.
✓ Branch 1 taken 4993 times.
✓ Branch 2 taken 4190 times.
✓ Branch 3 taken 830374 times.
✓ Branch 4 taken 6482 times.
✓ Branch 5 taken 2977 times.
854248 switch(clk)
10535 {
10536 case 0: // reposition him
10537 {
10538 6482 int32_t t=0;
10539 6482 int32_t pos2=zc_oldrand()%160 + 16;
10540 6482 bool placed=false;
10541
10542
4/4
✓ Branch 0 taken 6417 times.
✓ Branch 1 taken 38529 times.
✓ Branch 2 taken 26366 times.
✓ Branch 3 taken 5746 times.
44946 while(!placed && t<160)
10543 {
10544 26366 rpos_t rpos = POS_TO_RPOS(pos2, screen_spawned);
10545 90460 auto [sx, sy] = COMBOXY_REGION(rpos);
10546 26366 mapscr* s = get_scr(screen_spawned);
10547
10548 79098 int32_t watertype = iswaterex_z3(s->data[pos2], -1, sx, sy, false, true, true, (bool)(editorflags & ENEMY_FLAG7));
10549
5/6
✓ Branch 0 taken 6604 times.
✓ Branch 1 taken 19762 times.
✓ Branch 2 taken 6604 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 400 times.
✓ Branch 5 taken 5681 times.
32447 if(watertype && ((editorflags & ENEMY_FLAG6) ||
10550
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 6572 times.
6604 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
10551
3/4
✓ Branch 0 taken 6572 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6081 times.
✓ Branch 3 taken 6049 times.
6604 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
10552 {
10553 5681 x=sx;
10554 5681 y=sy;
10555
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 5341 times.
5681 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
10556 5681 hxofs=1000; // avoid hit detection
10557 5681 stunclk=0;
10558 5681 placed=true;
10559 5681 }
10560
10561 38464 pos2+=19;
10562
10563
2/2
✓ Branch 0 taken 33901 times.
✓ Branch 1 taken 4563 times.
38464 if(pos2>=176)
10564 4563 pos2-=160;
10565
10566 38464 ++t;
10567 }
10568
10569
3/4
✓ Branch 0 taken 5681 times.
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5681 times.
5746 if(!placed || whistleclk>=88) // can't place him, he's gone
10570 65 return true;
10571
10572 }
10573 5681 break;
10574
10575 case 35:
10576
2/2
✓ Branch 0 taken 3871 times.
✓ Branch 1 taken 1361 times.
5232 if(!get_qr(qr_NEWENEMYTILES))
10577 {
10578 1361 dir=(Hero.y+8<y)?up:down;
10579 1361 }
10580
10581 5232 hxofs=0;
10582 5232 break;
10583
10584 case 35+19:
10585 4993 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
10586 4993 sfx(wpnsfx(wpn),pan(x));
10587 4993 break;
10588
10589 case 35+66:
10590 4190 hxofs=1000;
10591 4190 break;
10592
10593 case 198:
10594 2977 clk=-1;
10595 2977 break;
10596 }
10597
10598 853447 return enemy::animate(index);
10599 856401 }
10600
10601 867086 void eZora::draw(BITMAP *dest)
10602 {
10603
2/2
✓ Branch 0 taken 20009 times.
✓ Branch 1 taken 847077 times.
867086 if (isSubmerged())
10604 20009 return;
10605
10606 847077 update_enemy_frame();
10607 847077 enemy::draw(dest);
10608 867086 }
10609
10610 867318 bool eZora::isSubmerged() const
10611 {
10612 867318 return clk < 3;
10613 }
10614
10615
3/6
✓ Branch 0 taken 50257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50257 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50257 times.
✗ Branch 5 not taken.
100514 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10616 50257 {
10617 50257 multishot= timer = fired = dashing = 0;
10618 50257 hashero = false;
10619 50257 dummy_bool[0]=false;
10620
4/8
✓ Branch 0 taken 50257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50257 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50257 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50257 times.
✗ Branch 7 not taken.
50257 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
10621
5/6
✓ Branch 0 taken 1002 times.
✓ Branch 1 taken 49255 times.
✓ Branch 2 taken 1002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 519 times.
✓ Branch 5 taken 483 times.
50257 if(dmisc9==e9tARMOS && zc_oldrand()&1)
10622 {
10623
2/4
✓ Branch 0 taken 519 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 519 times.
✗ Branch 3 not taken.
519 step=zslongToFix(dmisc10*100);
10624
10625
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 501 times.
519 if(anim==aARMOS4) o_tile+=20;
10626 519 }
10627
10628
3/4
✓ Branch 0 taken 50257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1002 times.
✓ Branch 3 taken 49255 times.
50257 if(flags & guy_fade_flicker)
10629 {
10630 1002 clk=0;
10631 1002 superman = 1;
10632 1002 fading=fade_flicker;
10633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1002 times.
1002 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10634 1002 dir=down;
10635
10636
4/6
✓ Branch 0 taken 1002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 561 times.
1002 if(!canmove(down,(zfix)8,spw_none,false))
10637
3/6
✓ Branch 0 taken 441 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 441 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 441 times.
✗ Branch 5 not taken.
441 clk3=int32_t(13.0/step);
10638 1002 }
10639
3/4
✓ Branch 0 taken 49255 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49122 times.
✓ Branch 3 taken 133 times.
49255 else if(flags & guy_fade_instant)
10640 {
10641 133 clk=0;
10642 133 }
10643
10644
1/2
✓ Branch 0 taken 50257 times.
✗ Branch 1 not taken.
50257 shadowdistance = 0;
10645 50257 clk4 = clk5 = 0;
10646 //nets+2380;
10647
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 50255 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
50257 if (SIZEflags != 0) init_size_flags();;
10648 50257 }
10649
10650 15823224 bool eStalfos::animate(int32_t index)
10651 {
10652
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 15822968 times.
15823224 if(switch_hooked) return enemy::animate(index);
10653
3/4
✓ Branch 0 taken 15822542 times.
✓ Branch 1 taken 426 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15822542 times.
15822968 if(fallclk||drownclk)
10654 {
10655 426 return enemy::animate(index);
10656 }
10657
2/2
✓ Branch 0 taken 353022 times.
✓ Branch 1 taken 15469520 times.
15822542 if(dying)
10658 {
10659
2/2
✓ Branch 0 taken 352974 times.
✓ Branch 1 taken 48 times.
353022 if(hashero)
10660 {
10661 48 Hero.setEaten(0);
10662 48 hashero=false;
10663 48 }
10664
10665
10/14
✓ Branch 0 taken 36032 times.
✓ Branch 1 taken 316990 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 32347 times.
✓ Branch 4 taken 187 times.
✓ Branch 5 taken 3498 times.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 187 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 187 times.
353022 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
10666 {
10667 187 hp=-1000;
10668
5/10
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 187 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
187 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
10669 187 Ewpns.add(ew);
10670 187 ew->fakez = fakez;
10671
10672
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
187 if(wpn==ewSBomb || wpn==ewBomb)
10673 {
10674 187 ew->step=0;
10675 187 ew->id=wpn;
10676 187 ew->misc=50;
10677 187 ew->clk=48;
10678 187 }
10679
10680 187 fired=true;
10681 187 }
10682
6/6
✓ Branch 0 taken 156368 times.
✓ Branch 1 taken 196467 times.
✓ Branch 2 taken 130316 times.
✓ Branch 3 taken 26052 times.
✓ Branch 4 taken 130298 times.
✓ Branch 5 taken 18 times.
352835 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
10683 {
10684
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
10685 {
10686 1 int32_t wpn2 = wpn+dmisc3;
10687
10688
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
10689 {
10690 wpn2=wpn;
10691 }
10692
10693 1 dummy_bool[0]=true;
10694 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
10695 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10696 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
10697 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10698 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
10699 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10700 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
10701 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10702 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
10703 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10704 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
10705 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10706 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
10707 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10708 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
10709 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10710 1 sfx(wpnsfx(wpn2),pan(x));
10711 1 }
10712 18 }
10713
10714 353022 KillWeapon();
10715 353022 return Dead(index);
10716 }
10717 //vire split
10718 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
10719 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
10720
13/14
✓ Branch 0 taken 21143 times.
✓ Branch 1 taken 15448377 times.
✓ Branch 2 taken 21143 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✓ Branch 5 taken 20792 times.
✓ Branch 6 taken 1192696 times.
✓ Branch 7 taken 14276473 times.
✓ Branch 8 taken 1191149 times.
✓ Branch 9 taken 1547 times.
✓ Branch 10 taken 6686 times.
✓ Branch 11 taken 1184463 times.
✓ Branch 12 taken 1326 times.
✓ Branch 13 taken 5360 times.
15469520 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
10721 {
10722 1677 stop_bgsfx(index);
10723 1677 int32_t kids = guys.Count();
10724 1677 int32_t id2=dmisc3;
10725
2/2
✓ Branch 0 taken 3307 times.
✓ Branch 1 taken 1677 times.
4984 for(int32_t i=0; i < dmisc4; i++)
10726 {
10727
4/6
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 2035 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2035 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3307 times.
3307 if(addenemy(screen_spawned,x,y,id2+(guysbuf[id2].type==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
10728 3307 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10729 3307 }
10730
10731
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1676 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1677 if (itemguy && guys.Count()) // Hand down the carried item
10732 {
10733 1 int guycarryingitem = guys.Count()-1;
10734 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10735 1 itemguy = false;
10736 1 }
10737
10738
2/2
✓ Branch 0 taken 1660 times.
✓ Branch 1 taken 17 times.
1677 if(hashero)
10739 {
10740 17 Hero.setEaten(0);
10741 17 hashero=false;
10742 17 }
10743
10744
4/4
✓ Branch 0 taken 1649 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 1326 times.
✓ Branch 3 taken 323 times.
1677 if(deadsfx > 0 && dmisc2==e2tSPLIT)
10745 323 sfx(deadsfx,pan(x));
10746
10747 1677 return true;
10748 }
10749
10750
2/2
✓ Branch 0 taken 71161 times.
✓ Branch 1 taken 15396682 times.
15467843 if(fading)
10751 {
10752
2/2
✓ Branch 0 taken 1228 times.
✓ Branch 1 taken 69933 times.
71161 if(++clk4 > 60)
10753 {
10754 1228 clk4=0;
10755 1228 superman=0;
10756 1228 fading=0;
10757
10758
4/6
✓ Branch 0 taken 967 times.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 967 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 967 times.
1228 if(flags&guy_armos && z==0 && fakez == 0)
10759 {
10760 //if a custom size (not 16px by 16px)
10761
10762 //if a custom size (not 16px by 16px)
10763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 967 times.
967 if (ffcactivated)
10764 removearmosffc(*ffcactivated);
10765 else
10766 {
10767
4/8
✓ Branch 0 taken 967 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 967 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 967 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 967 times.
967 if (txsz > 1 || tysz > 1 || (SIZEflags&OVERRIDE_HIT_WIDTH) || (SIZEflags&OVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
10768 {
10769 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
10770 for(int32_t dx = 0; dx < tysz; dx ++)
10771 {
10772 for(int32_t dy = 0; dy < tysz; dy++)
10773 {
10774 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
10775 did_armos = false;
10776 }
10777 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
10778 did_armos = false;
10779 }
10780 for(int32_t dy = 0; dy < tysz; dy ++)
10781 {
10782 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
10783 did_armos = false;
10784 }
10785 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
10786 }
10787 967 else removearmos(x,y);
10788 }
10789
10790 967 }
10791
10792 1228 clk2=0;
10793
10794 1228 newdir();
10795 1228 }
10796 69933 else return enemy::animate(index);
10797 1228 }
10798
6/8
✓ Branch 0 taken 148409 times.
✓ Branch 1 taken 15248273 times.
✓ Branch 2 taken 148409 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 148409 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 138854 times.
✓ Branch 7 taken 9555 times.
15396682 else if(flags&guy_armos && z==0 && fakez == 0 && clk==0)
10799 9555 removearmos(x,y,ffcactivated);
10800
10801
10802
2/2
✓ Branch 0 taken 7207 times.
✓ Branch 1 taken 15390703 times.
15397910 if(hashero)
10803 {
10804 7207 Hero.setX(x);
10805 7207 Hero.setY(y);
10806 7207 ++clk2;
10807
10808
4/4
✓ Branch 0 taken 5694 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 6308 times.
✓ Branch 3 taken 899 times.
7207 if(clk2==(dmisc8==0 ? 95 : dmisc8))
10809 {
10810
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 877 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
899 switch(dmisc7)
10811 {
10812 case e7tEATITEMS:
10813 {
10814
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<MAXITEMS; i++)
10815 {
10816
2/2
✓ Branch 0 taken 5610 times.
✓ Branch 1 taken 22 times.
5632 if(itemsbuf[i].flags&item_edible)
10817 22 game->set_item(i, false);
10818 5632 }
10819
10820 22 break;
10821 }
10822
10823 case e7tEATMAGIC:
10824 game->change_dmagic(-1*game->get_magicdrainrate());
10825 break;
10826
10827 case e7tEATRUPEES:
10828 game->change_drupy(-1);
10829 break;
10830 }
10831
10832 899 clk2=0;
10833 899 }
10834
10835
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 6661 times.
7207 if((clk&0x18)==8) // stop its animation on the middle frame
10836 6661 --clk;
10837 7207 }
10838
4/4
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14341830 times.
✓ Branch 2 taken 616037 times.
✓ Branch 3 taken 432836 times.
15390703 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
10839 {
10840 // Movement engine
10841
6/6
✓ Branch 0 taken 839470 times.
✓ Branch 1 taken 14118397 times.
✓ Branch 2 taken 3294 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 14114936 times.
✓ Branch 5 taken 59 times.
14957867 if(clk>=0) switch(id>>12)
10842 {
10843 case 0: // Normal movement
10844
10845 /*
10846 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
10847 {
10848 // Overloading clk4 (Tribble clock) here...
10849 step=17/100.0;
10850 if(clk4<32) misc=1;
10851 else if(clk4<48) misc=2;
10852 else if(clk4<300) { misc=3; step = dstep/100.0; }
10853 else if(clk4<316) misc=2;
10854 else if(clk4<412) misc=1;
10855 else if(clk4<540) { misc=0; step=0; }
10856 else clk4=0;
10857 if(clk4==48) clk=0;
10858 hxofs=(misc>=2)?0:1000;
10859 if (dmisc9==e9tLEEVER)
10860 variable_walk(rate, homing, 0);
10861 else
10862 variable_walk_8(rate, homing, 4, 0);
10863 break;
10864 }
10865 */
10866
4/4
✓ Branch 0 taken 13735902 times.
✓ Branch 1 taken 379034 times.
✓ Branch 2 taken 417076 times.
✓ Branch 3 taken 13318826 times.
14114936 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
10867 {
10868 796110 vire_hop();
10869 796110 break;
10870 }
10871
2/2
✓ Branch 0 taken 984687 times.
✓ Branch 1 taken 12334139 times.
13318826 else if(dmisc9==e9tROPE) //Rope charge
10872 {
10873
9/10
✓ Branch 0 taken 967265 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 138779 times.
✓ Branch 3 taken 828486 times.
✓ Branch 4 taken 126694 times.
✓ Branch 5 taken 12085 times.
✓ Branch 6 taken 125869 times.
✓ Branch 7 taken 825 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 125869 times.
984687 if(!fired && dashing && !stunclk && !watch && !frozenclock)
10874 {
10875
5/6
✓ Branch 0 taken 9076 times.
✓ Branch 1 taken 116793 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 9029 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
125869 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
10876 {
10877
10878
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 33 times.
47 if ( get_qr(qr_BOMBCHUSUPERBOMB) )
10879 {
10880 14 hp=-1000;
10881
10882
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10883 {
10884
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
10885 14 Ewpns.add(ew);
10886 14 ew->fakez = fakez;
10887
10888
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
10889 {
10890 14 ew->step=0;
10891 14 ew->id=wpn+dmisc3;
10892 14 ew->misc=50;
10893 14 ew->clk=48;
10894 14 }
10895
10896 14 fired=true;
10897 14 }
10898 else
10899 {
10900 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
10901 Ewpns.add(ew);
10902 ew->fakez = fakez;
10903
10904 if(wpn==ewSBomb || wpn==ewBomb)
10905 {
10906 ew->step=0;
10907 ew->id=wpn;
10908 ew->misc=50;
10909 ew->clk=48;
10910 }
10911
10912 fired=true;
10913 }
10914 14 }
10915
10916 else
10917 {
10918 33 hp=-1000;
10919
10920 int32_t wpn2;
10921
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10922 33 wpn2=wpn;
10923 else
10924 wpn2=wpn;
10925
10926
5/10
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 33 times.
✗ Branch 9 not taken.
33 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
10927 33 Ewpns.add(ew);
10928 33 ew->fakez = fakez;
10929
10930
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
33 if(wpn2==ewSBomb || wpn2==ewBomb)
10931 {
10932 33 ew->step=0;
10933 33 ew->id=wpn2;
10934 33 ew->misc=50;
10935 33 ew->clk=48;
10936 33 }
10937
10938 33 fired=true;
10939 }
10940 47 }
10941 125869 }
10942
10943 984687 charge_attack();
10944 984687 break;
10945 }
10946 /*
10947 * Boomerang-throwers have a halt count of 1
10948 * Zols have a halt count of (zc_oldrand()&7)<<4
10949 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
10950 * Everything else has 48
10951 */
10952 else
10953 {
10954
2/2
✓ Branch 0 taken 568419 times.
✓ Branch 1 taken 11765720 times.
12334139 if(wpn==ewBrang) // Goriya
10955 {
10956 568419 halting_walk(rate,homing,0,hrate, 1);
10957 568419 }
10958
4/4
✓ Branch 0 taken 11616344 times.
✓ Branch 1 taken 149376 times.
✓ Branch 2 taken 4552225 times.
✓ Branch 3 taken 7064119 times.
11765720 else if(dmisc9==e9tNORMAL && wpn==0)
10959 {
10960
2/2
✓ Branch 0 taken 717973 times.
✓ Branch 1 taken 6346146 times.
7064119 if(dmisc2==e2tSPLITHIT) // Zol
10961 {
10962 717973 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
10963 717973 }
10964
4/4
✓ Branch 0 taken 1754155 times.
✓ Branch 1 taken 4591991 times.
✓ Branch 2 taken 1538264 times.
✓ Branch 3 taken 215891 times.
6346146 else if(frate<=8 && starting_hp==1) // Gel
10965 {
10966 215891 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
10967 215891 }
10968 else // Other
10969 {
10970 6130255 halting_walk(rate,homing,0,hrate, 48);
10971 }
10972 7064119 }
10973 else // Other
10974 {
10975 4701601 halting_walk(rate,homing,0,hrate, 48);
10976 }
10977 }
10978
10979 //if not in midair, and Hero's swinging sword is nearby, jump.
10980 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
10981 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
10982 {
10983 facehero(false);
10984 sclk=16+((dir^1)<<8);
10985 fall=-FEATHERJUMP;
10986 sfx(WAV_ZN1JUMP,pan(x));
10987 }*/
10988 12334139 break;
10989
10990 // Following cases are for just after creation-by-splitting.
10991 case 1:
10992
2/2
✓ Branch 0 taken 2473 times.
✓ Branch 1 taken 821 times.
3294 if(misc==1)
10993 {
10994 821 dir=up;
10995 821 step=8;
10996 821 }
10997
10998
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 2504 times.
3294 if(misc<=2)
10999 {
11000 2504 move(step);
11001
11002
2/2
✓ Branch 0 taken 1992 times.
✓ Branch 1 taken 512 times.
2504 if(!canmove(dir,(zfix)0,0,false))
11003 512 dir=down;
11004 2504 }
11005
11006
2/2
✓ Branch 0 taken 2504 times.
✓ Branch 1 taken 790 times.
3294 if(misc==3)
11007 {
11008
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 503 times.
790 if(canmove(right,(zfix)16,0,false))
11009 503 x+=16;
11010 790 }
11011
11012 3294 ++misc;
11013 3294 break;
11014
11015 case 2:
11016
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 15 times.
59 if(misc==1)
11017 {
11018 15 dir=down;
11019 15 step=8;
11020 15 }
11021
11022
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 45 times.
59 if(misc<=2)
11023 {
11024 45 move(step);
11025 /*
11026 if(!canmove(dir,(zfix)0,0,false))
11027 dir=up;
11028 */
11029 45 }
11030
11031
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 14 times.
59 if(misc==3)
11032 {
11033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(canmove(left,(zfix)16,0,false))
11034 14 x-=16;
11035 14 }
11036
11037 59 ++misc;
11038 59 break;
11039
11040 default:
11041
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 28 times.
108 if(misc==1)
11042 {
11043 28 dir=(zc_oldrand()%4);
11044 28 step=8;
11045 28 }
11046
11047
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 83 times.
108 if(misc<=2)
11048 {
11049 83 move(step);
11050
11051
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 2 times.
83 if(!canmove(dir,(zfix)0,0,false))
11052 2 dir=dir^1;
11053 83 }
11054
11055
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 25 times.
108 if(misc==3)
11056 {
11057
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
25 if(dir >= left && canmove(dir,(zfix)16,0,false))
11058 8 x+=(dir==left ? -16 : 16);
11059 25 }
11060
11061 108 ++misc;
11062 108 break;
11063 14118397 }
11064
11065
4/4
✓ Branch 0 taken 25272 times.
✓ Branch 1 taken 14932595 times.
✓ Branch 2 taken 24443 times.
✓ Branch 3 taken 829 times.
14957867 if(id>>12 && misc>=4) //recently spawned by a split enemy
11066 {
11067 829 id&=0xFFF;
11068 829 step = zslongToFix(dstep*100);
11069
11070
1/2
✓ Branch 0 taken 829 times.
✗ Branch 1 not taken.
829 if(x<32) x=32;
11071
11072
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 21 times.
829 if(x>world_w-48) x=world_w-48;
11073
11074
2/2
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 24 times.
829 if(y<32) y=32;
11075
11076
2/2
✓ Branch 0 taken 822 times.
✓ Branch 1 taken 7 times.
829 if(y>world_h-48) y=world_h-48;
11077
11078 829 misc=3;
11079 829 }
11080 14957867 }
11081 else
11082 {
11083 //sfx(wpnsfx(wpn),pan(x));
11084
1/2
✓ Branch 0 taken 432836 times.
✗ Branch 1 not taken.
432836 if(clk2>2) clk2--;
11085 }
11086
11087 // Fire Zol
11088
8/8
✓ Branch 0 taken 6104972 times.
✓ Branch 1 taken 9292938 times.
✓ Branch 2 taken 139281 times.
✓ Branch 3 taken 5965691 times.
✓ Branch 4 taken 1131 times.
✓ Branch 5 taken 138150 times.
✓ Branch 6 taken 1102 times.
✓ Branch 7 taken 29 times.
15397910 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
11089 {
11090 1102 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
11091 1102 sfx(wpnsfx(wpn),pan(x));
11092
11093 1102 int32_t i=Ewpns.Count()-1;
11094 1102 weapon *ew = (weapon*)(Ewpns.spr(i));
11095
11096
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1102 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
11097 {
11098 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
11099 if ( ew->do_animation ) ew->tile+=ew->aframe;
11100 }
11101 1102 }
11102 // Goriya
11103
14/16
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14347935 times.
✓ Branch 2 taken 468534 times.
✓ Branch 3 taken 580339 times.
✓ Branch 4 taken 456235 times.
✓ Branch 5 taken 12299 times.
✓ Branch 6 taken 423258 times.
✓ Branch 7 taken 32977 times.
✓ Branch 8 taken 423258 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 420517 times.
✓ Branch 11 taken 2741 times.
✓ Branch 12 taken 420517 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 414155 times.
✓ Branch 15 taken 6362 times.
15396808 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
11104 {
11105 6362 misc=index+100;
11106
7/14
✓ Branch 0 taken 6362 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6362 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6362 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6362 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6362 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6362 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6362 times.
✗ Branch 13 not taken.
6362 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
11107 6362 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
11108
11109
2/2
✓ Branch 0 taken 6105 times.
✓ Branch 1 taken 257 times.
6362 if(dmisc1==2)
11110 {
11111 257 int32_t ndir=dir;
11112
11113
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 251 times.
257 if(Hero.x-x==0)
11114 {
11115 6 ndir=(Hero.y+8<y)?up:down;
11116 6 }
11117 else //turn to face Hero
11118 {
11119 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11120 251 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11121
11122
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 193 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 13 times.
251 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
11123 {
11124 13 ndir=down;
11125 13 }
11126
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 68 times.
238 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
11127 {
11128 68 ndir=right;
11129 68 }
11130
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 48 times.
170 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
11131 {
11132 48 ndir=up;
11133 48 }
11134 else
11135 {
11136 122 ndir=left;
11137 }
11138 }
11139
11140 257 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
11141
11142
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 223 times.
257 if(canmove(ndir,false))
11143 {
11144 223 dir=ndir;
11145 223 }
11146 257 }
11147 6362 }
11148
15/16
✓ Branch 0 taken 15331557 times.
✓ Branch 1 taken 58889 times.
✓ Branch 2 taken 221201 times.
✓ Branch 3 taken 15169245 times.
✓ Branch 4 taken 195083 times.
✓ Branch 5 taken 26118 times.
✓ Branch 6 taken 170191 times.
✓ Branch 7 taken 24892 times.
✓ Branch 8 taken 168807 times.
✓ Branch 9 taken 1384 times.
✓ Branch 10 taken 153707 times.
✓ Branch 11 taken 15100 times.
✓ Branch 12 taken 153707 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 152763 times.
15390446 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
11149
3/3
✓ Branch 0 taken 26125 times.
✓ Branch 1 taken 125732 times.
✓ Branch 2 taken 906 times.
152763 switch(dmisc1)
11150 {
11151 case e1tCONSTANT: //Deathnut
11152 {
11153 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
11154
2/2
✓ Branch 0 taken 123149 times.
✓ Branch 1 taken 2583 times.
125732 if(clk5>64)
11155 {
11156 2583 clk5=0;
11157 2583 fired=false;
11158 2583 }
11159
11160 125732 clk5+=(zc_oldrand()&3);
11161
11162
4/4
✓ Branch 0 taken 76714 times.
✓ Branch 1 taken 49018 times.
✓ Branch 2 taken 25645 times.
✓ Branch 3 taken 51069 times.
125732 if((clk5>24)&&(clk5<52))
11163 {
11164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51069 times.
51069 if ( do_animation )tile+=20; //firing
11165
11166
4/4
✓ Branch 0 taken 27958 times.
✓ Branch 1 taken 23111 times.
✓ Branch 2 taken 25131 times.
✓ Branch 3 taken 2827 times.
51069 if(!fired&&(clk5>=38))
11167 {
11168
5/10
✓ Branch 0 taken 2827 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2827 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2827 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2827 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2827 times.
✗ Branch 9 not taken.
2827 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
11169 2827 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
11170 2827 sfx(wpnsfx(wpn),pan(x));
11171 2827 fired=true;
11172 2827 }
11173 51069 }
11174
11175 125732 break;
11176 }
11177
11178 case e1tFIREOCTO: //Fire Octo
11179 906 timer=zc_oldrand()%50+50;
11180 906 break;
11181
11182 default:
11183 26125 FireWeapon();
11184 26125 break;
11185 152763 }
11186
11187 /* Fire again if:
11188 * - clk2 about to run out
11189 * - not already double-firing (dmisc1 is 1)
11190 * - not carrying Hero
11191 * - one in 0xF chance
11192 */
11193
8/10
✓ Branch 0 taken 524941 times.
✓ Branch 1 taken 14872969 times.
✓ Branch 2 taken 4002 times.
✓ Branch 3 taken 520939 times.
✓ Branch 4 taken 4002 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4002 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3751 times.
✓ Branch 9 taken 251 times.
15397910 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
11194 {
11195 #if 1
11196 251 newdir(rate, homing, grumble);
11197 #else
11198 dir^=2;
11199 #endif
11200 251 clk2=28;
11201 251 ++multishot;
11202 251 }
11203
11204
2/2
✓ Branch 0 taken 3492813 times.
✓ Branch 1 taken 11905097 times.
15397910 if(clk2==0)
11205 {
11206 11905097 multishot = 0;
11207 11905097 }
11208
11209
2/2
✓ Branch 0 taken 15333600 times.
✓ Branch 1 taken 64310 times.
15397910 if(timer) //Fire Octo
11210 {
11211 64310 clk2=15; //this keeps the octo in place until he's done firing
11212
11213
2/2
✓ Branch 0 taken 48558 times.
✓ Branch 1 taken 15752 times.
64310 if(!(timer%4))
11214 {
11215 15752 FireBreath(false);
11216 15752 }
11217
11218 64310 --timer;
11219 64310 }
11220
11221
2/2
✓ Branch 0 taken 15148517 times.
✓ Branch 1 taken 249393 times.
15397910 if(dmisc2==e2tTRIBBLE)
11222 249393 ++clk4;
11223
11224
7/10
✓ Branch 0 taken 4480 times.
✓ Branch 1 taken 15393430 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 15397217 times.
✓ Branch 4 taken 693 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 693 times.
15397910 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
11225 {
11226 693 int32_t kids = guys.Count();
11227 693 int32_t id2=dmisc3;
11228
11229
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 693 times.
1386 for(int32_t i=0; i<dmisc4; i++)
11230 {
11231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if(addenemy(screen_spawned,x,y,id2,-24))
11232 {
11233
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(itemguy) // Hand down the carried item
11234 {
11235 int guycarryingitem = guys.Count()-1;
11236 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11237 itemguy = false;
11238 }
11239
11240 693 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11241 693 }
11242 693 }
11243
11244
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(hashero)
11245 {
11246 Hero.setEaten(0);
11247 hashero=false;
11248 }
11249
11250 693 stop_bgsfx(index);
11251 693 return true;
11252 }
11253
11254 15397217 return enemy::animate(index);
11255 15823224 }
11256
11257 16245517 void eStalfos::draw(BITMAP *dest)
11258 {
11259 16245517 update_enemy_frame();
11260
11261
7/8
✓ Branch 0 taken 16245091 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 16245091 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86951 times.
✓ Branch 5 taken 16158140 times.
✓ Branch 6 taken 75836 times.
✓ Branch 7 taken 11115 times.
16245517 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
11262 {
11263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11115 times.
11115 if ( do_animation )tile+=20;
11264 11115 }
11265
11266 16245517 enemy::draw(dest);
11267 16245517 }
11268
11269 7536565 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
11270 {
11271 7536565 int32_t tempy=yofs;
11272
11273
4/4
✓ Branch 0 taken 7321147 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7224946 times.
✓ Branch 3 taken 311619 times.
7536565 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS))
11274 {
11275 311619 flip = 0;
11276 311619 int32_t fdiv = frate/4;
11277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 311619 times.
311619 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11278
11279
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11280 311619 efrate:((clk>=(frate>>1))?1:0);
11281 311619 shadowtile = wpnsbuf[spr_shadow].tile;
11282
11283
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 if(get_qr(qr_NEWENEMYTILES))
11284 {
11285 311619 shadowtile+=f2;
11286 311619 }
11287 else
11288 {
11289 shadowtile+=f2?1:0;
11290 }
11291
11292 311619 yofs+=shadowdistance;
11293 311619 yofs+=8;
11294 311619 }
11295
4/4
✓ Branch 0 taken 7321147 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7533530 times.
✓ Branch 3 taken 3035 times.
7536565 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW))
11296 {
11297 3035 flip = 0;
11298 3035 int32_t fdiv = frate/4;
11299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3035 times.
3035 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11300
11301
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11302 3035 efrate:((clk>=(frate>>1))?1:0);
11303 3035 shadowtile = wpnsbuf[spr_shadow].tile;
11304
11305
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 if(get_qr(qr_NEWENEMYTILES))
11306 {
11307 3035 shadowtile+=f2;
11308 3035 }
11309 else
11310 {
11311 shadowtile+=f2?1:0;
11312 }
11313 3035 }
11314
2/2
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 7531069 times.
7536565 if(!shadow_overpit(this))
11315 7531069 enemy::drawshadow(dest, translucent);
11316 7536565 yofs=tempy;
11317 7536565 }
11318
11319 157815 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
11320 {
11321 157815 int32_t wpnId = w->id;
11322 157815 int32_t wpnDir = w->dir;
11323
11324
4/4
✓ Branch 0 taken 1418 times.
✓ Branch 1 taken 156397 times.
✓ Branch 2 taken 609 times.
✓ Branch 3 taken 809 times.
157815 if(wpnId==wHammer && shield && (flags & guy_bkshield)
11325
6/8
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 385 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 265 times.
✓ Branch 5 taken 120 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 120 times.
609 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
11326
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
120 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
11327 {
11328 265 shield = false;
11329 265 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
11330
11331
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 243 times.
265 if(get_qr(qr_BRKNSHLDTILES))
11332 243 o_tile=s_tile;
11333 265 }
11334
11335 157815 int32_t ret = enemy::takehit(w,realweap);
11336
11337
4/4
✓ Branch 0 taken 22327 times.
✓ Branch 1 taken 135488 times.
✓ Branch 2 taken 20576 times.
✓ Branch 3 taken 1751 times.
157815 if(sclk && dmisc2==e2tSPLITHIT)
11338 1751 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
11339
11340 157815 return ret;
11341 }
11342
11343 984687 void eStalfos::charge_attack()
11344 {
11345
2/2
✓ Branch 0 taken 6715 times.
✓ Branch 1 taken 977972 times.
984687 if(slide())
11346 6715 return;
11347
11348
10/12
✓ Branch 0 taken 977972 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 975568 times.
✓ Branch 3 taken 2404 times.
✓ Branch 4 taken 946055 times.
✓ Branch 5 taken 29513 times.
✓ Branch 6 taken 924502 times.
✓ Branch 7 taken 21553 times.
✓ Branch 8 taken 918879 times.
✓ Branch 9 taken 5623 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 918879 times.
977972 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
11349 59093 return;
11350
11351
2/2
✓ Branch 0 taken 37515 times.
✓ Branch 1 taken 881364 times.
918879 if(clk3<=0)
11352 {
11353 37515 fix_coords(true);
11354
11355
2/2
✓ Branch 0 taken 10043 times.
✓ Branch 1 taken 27472 times.
37515 if(!dashing)
11356 {
11357 27472 int32_t ldir = lined_up(7,false);
11358
11359
4/4
✓ Branch 0 taken 3107 times.
✓ Branch 1 taken 24365 times.
✓ Branch 2 taken 456 times.
✓ Branch 3 taken 2651 times.
27472 if(ldir!=-1 && canmove(ldir,false))
11360 {
11361 2651 dir=ldir;
11362 2651 dashing=true;
11363
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2651 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2651 if (dmisc10<=0 || replay_version_check(0,33) || get_qr(qr_ROPE_ENEMIES_SPEED_NOT_CONFIGURABLE))
11364 2651 step=zslongToFix(dstep*100)+1;
11365 else
11366 step=zslongToFix(dmisc10*100);
11367 2651 }
11368 24821 else newdir(4,0,0);
11369 27472 }
11370
11371
2/2
✓ Branch 0 taken 36061 times.
✓ Branch 1 taken 1454 times.
37515 if(!canmove(dir,false))
11372 {
11373 1454 step=zslongToFix(dstep*100);
11374 1454 newdir();
11375 1454 dashing=false;
11376 1454 }
11377
11378 37515 zfix div = step;
11379
11380
1/2
✓ Branch 0 taken 37515 times.
✗ Branch 1 not taken.
37515 if(div == 0)
11381 div = 1;
11382
11383 37515 clk3=(int32_t)(16.0/div);
11384 37515 return;
11385 }
11386
11387 881364 move(step);
11388 881364 --clk3;
11389 984687 }
11390
11391 796110 void eStalfos::vire_hop()
11392 {
11393
2/2
✓ Branch 0 taken 379034 times.
✓ Branch 1 taken 417076 times.
796110 if(dmisc9!=e9tPOLSVOICE)
11394 {
11395
2/2
✓ Branch 0 taken 372449 times.
✓ Branch 1 taken 6585 times.
379034 if(sclk!=0)
11396 {
11397
2/2
✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 3843 times.
6585 if (dmisc2==e2tSPLITHIT) return;
11398 3843 }
11399 376292 }
11400 417076 else sclk=0;
11401
11402
8/12
✓ Branch 0 taken 793368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 793368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 777885 times.
✓ Branch 5 taken 15483 times.
✓ Branch 6 taken 761476 times.
✓ Branch 7 taken 16409 times.
✓ Branch 8 taken 761476 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 761476 times.
793368 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
11403 31892 return;
11404
11405 761476 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
11406 int32_t jump_height;
11407
11408
1/2
✓ Branch 0 taken 761476 times.
✗ Branch 1 not taken.
761476 if ((dmisc10 <= 0))
11409 761476 jump_height = (dmisc9 == e9tPOLSVOICE) ? 27 : 16;
11410 else jump_height = dmisc10;
11411
11412 761476 y=floor_y;
11413
11414
2/2
✓ Branch 0 taken 735218 times.
✓ Branch 1 taken 26258 times.
761476 if(clk3<=0)
11415 {
11416 26258 fix_coords();
11417
11418 //z=0;
11419 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
11420 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
11421
9/10
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 602 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 4226 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
26258 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & move_obeys_grav)))) //Vires in old quests
11422 22032 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
11423
11424
2/2
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
26258 if(clk2<=0)
11425 {
11426 //z=0;
11427
6/6
✓ Branch 0 taken 19015 times.
✓ Branch 1 taken 2321 times.
✓ Branch 2 taken 18569 times.
✓ Branch 3 taken 446 times.
✓ Branch 4 taken 14491 times.
✓ Branch 5 taken 4078 times.
21336 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
11428 {
11429
11430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17258 times.
17258 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
11431 17258 }
11432 21336 }
11433
11434
4/4
✓ Branch 0 taken 12099 times.
✓ Branch 1 taken 14159 times.
✓ Branch 2 taken 5069 times.
✓ Branch 3 taken 7030 times.
26258 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
11435 {
11436 7030 clk2=int32_t((16.0*jump_width)/step.getFloat());
11437 7030 }
11438
11439 26258 clk3=int32_t(16.0/step.getFloat());
11440 26258 }
11441
11442 761476 --clk3;
11443
11444
3/4
✓ Branch 0 taken 361067 times.
✓ Branch 1 taken 400409 times.
✓ Branch 2 taken 361067 times.
✗ Branch 3 not taken.
761476 if(dmisc9==e9tPOLSVOICE || clk2>0)
11445 761476 move(step);
11446
11447 761476 floor_y=y;
11448 761476 clk2--;
11449
11450 //if we're in the middle of a jump
11451
6/6
✓ Branch 0 taken 624929 times.
✓ Branch 1 taken 136547 times.
✓ Branch 2 taken 257704 times.
✓ Branch 3 taken 367225 times.
✓ Branch 4 taken 110653 times.
✓ Branch 5 taken 147051 times.
761476 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
11452 {
11453 477878 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
11454
11455
4/4
✓ Branch 0 taken 99298 times.
✓ Branch 1 taken 378580 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 93147 times.
477878 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11456 {
11457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93147 times.
93147 if (moveflags & move_use_fake_z) fakez=h;
11458 93147 else z=h;
11459 93147 }
11460 else
11461 {
11462 384731 y=floor_y-h;
11463 384731 shadowdistance=h;
11464 }
11465 477878 }
11466 else
11467 283598 shadowdistance = 0;
11468 796110 }
11469
11470 138 void eStalfos::eathero()
11471 {
11472
5/8
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 70 times.
138 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
11473 {
11474 70 hashero=true;
11475 70 y=floor_y;
11476 70 z=0;
11477
11478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(Hero.isSwimming())
11479 {
11480 Hero.setX(x);
11481 Hero.setY(y);
11482 }
11483 else
11484 {
11485 70 x=Hero.getX();
11486 70 y=Hero.getY();
11487 }
11488
11489 70 clk2=0;
11490 70 }
11491 138 }
11492
11493 1469390 bool eStalfos::WeaponOut()
11494 {
11495
2/2
✓ Branch 0 taken 2400579 times.
✓ Branch 1 taken 622399 times.
3022978 for(int32_t i=0; i<Ewpns.Count(); i++)
11496 {
11497
3/4
✓ Branch 0 taken 846991 times.
✓ Branch 1 taken 1553588 times.
✓ Branch 2 taken 846991 times.
✗ Branch 3 not taken.
2400579 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
11498 {
11499 846991 return true;
11500 }
11501 1553588 }
11502
11503 622399 return false;
11504 1469390 }
11505
11506 353022 void eStalfos::KillWeapon()
11507 {
11508
2/2
✓ Branch 0 taken 293384 times.
✓ Branch 1 taken 353022 times.
646406 for(int32_t i=0; i<Ewpns.Count(); i++)
11509 {
11510
4/4
✓ Branch 0 taken 245286 times.
✓ Branch 1 taken 48098 times.
✓ Branch 2 taken 244476 times.
✓ Branch 3 taken 810 times.
293384 if(((weapon*)Ewpns.spr(i))->level==misc && Ewpns.spr(i)->id==ewBrang)
11511 {
11512 //only kill this Goriya's boomerang -DD
11513
2/2
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 411 times.
810 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
11514 {
11515 411 Ewpns.del(i);
11516 411 }
11517 810 }
11518 293384 }
11519 353022 }
11520
11521 void eStalfos::break_shield()
11522 {
11523 if(!shield)
11524 return;
11525
11526 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
11527 shield=false;
11528
11529 if(get_qr(qr_BRKNSHLDTILES))
11530 o_tile=s_tile;
11531 }
11532
11533 void eStalfos::repair_shield()
11534 {
11535 if (shield)
11536 return;
11537
11538 shield = true;
11539
11540 if (get_qr(qr_BRKNSHLDTILES))
11541 {
11542 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
11543 else o_tile = d->tile;
11544 }
11545 }
11546
11547 13720 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11548 13720 {
11549
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 dir=(zc_oldrand()&7)+8;
11550
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 step=0;
11551 13720 movestatus=1;
11552
3/4
✓ Branch 0 taken 10596 times.
✓ Branch 1 taken 3124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10596 times.
13720 if (dmisc1 != 1 && dmisc19 > 0)
11553 {
11554 step = dmisc19/100.0;
11555 movestatus = 1;
11556 }
11557
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if (dmisc1 == 2) movestatus=2;
11558 13720 c=0;
11559 13720 clk4=0;
11560 //nets;
11561
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 init_size_flags();
11562 13720 dummy_int[1]=0;
11563 13720 }
11564
11565 3535341 bool eKeese::animate(int32_t index)
11566 {
11567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3535341 times.
3535341 if(switch_hooked) return enemy::animate(index);
11568
2/4
✓ Branch 0 taken 3535341 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3535341 times.
3535341 if(fallclk||drownclk) return enemy::animate(index);
11569
2/2
✓ Branch 0 taken 124509 times.
✓ Branch 1 taken 3410832 times.
3535341 if(dying)
11570 124509 return Dead(index);
11571
11572
2/2
✓ Branch 0 taken 3384641 times.
✓ Branch 1 taken 26191 times.
3410832 if(clk==0)
11573 {
11574 26191 removearmos(x,y,ffcactivated);
11575 26191 }
11576
11577
2/2
✓ Branch 0 taken 1025042 times.
✓ Branch 1 taken 2385790 times.
3410832 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
11578 {
11579 1025042 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
11580 1025042 }
11581 else
11582 {
11583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2385790 times.
2385790 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
11584 2385790 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
11585 }
11586
11587
2/2
✓ Branch 0 taken 120338 times.
✓ Branch 1 taken 3290494 times.
3410832 if(dmisc2 == e2tKEESETRIB)
11588 {
11589
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120338 times.
✓ Branch 2 taken 120147 times.
✓ Branch 3 taken 191 times.
120338 if(++clk4==(dmisc20>0?dmisc20:256))
11590 {
11591
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 105 times.
191 if(!m_walkflag(x,y,0, dir))
11592 {
11593 105 int32_t kids = guys.Count();
11594 105 bool success = false;
11595 105 int32_t id2=dmisc3;
11596 105 success = 0 != addenemy(screen_spawned,(zfix)x,(zfix)y,id2,-24);
11597
11598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(success)
11599 {
11600
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(itemguy) // Hand down the carried item
11601 {
11602 int guycarryingitem = guys.Count()-1;
11603 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11604 itemguy = false;
11605 }
11606
11607 105 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
11608 105 }
11609
11610 105 stop_bgsfx(index);
11611 105 return true;
11612 }
11613 else
11614 {
11615 86 clk4=0;
11616 }
11617 86 }
11618 120233 }
11619 // Keese Tribbles stay on the ground, so there's no problem when they transform.
11620
3/4
✓ Branch 0 taken 845879 times.
✓ Branch 1 taken 2444615 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 845879 times.
3290494 else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11621 {
11622
2/2
✓ Branch 0 taken 687068 times.
✓ Branch 1 taken 158811 times.
845879 if (get_qr(qr_OLD_KEESE_Z_AXIS))
11623 {
11624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687068 times.
687068 if (moveflags & move_use_fake_z)
11625 {
11626 fakez=int32_t(step/zslongToFix(dstep*100));
11627 // Some variance in keese flight heights when away from Hero
11628 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11629
11630 }
11631 else
11632 {
11633 687068 z=int32_t(step/zslongToFix(dstep*100));
11634 // Some variance in keese flight heights when away from Hero
11635
2/2
✓ Branch 0 taken 503635 times.
✓ Branch 1 taken 183433 times.
687068 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11636 }
11637 687068 }
11638 else
11639 {
11640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158811 times.
158811 if (moveflags & move_use_fake_z)
11641 {
11642 fakez=int32_t(step/zslongToFix(dstep*100));
11643 // Some variance in keese flight heights when away from Hero
11644 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11645
11646 }
11647 else
11648 {
11649 158811 z=int32_t(step/zslongToFix(dstep*100));
11650 // Some variance in keese flight heights when away from Hero
11651
2/2
✓ Branch 0 taken 16841 times.
✓ Branch 1 taken 141970 times.
158811 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11652 }
11653 }
11654 845879 }
11655
11656 3410727 return enemy::animate(index);
11657 3535341 }
11658
11659 2088281 void eKeese::drawshadow(BITMAP *dest, bool translucent)
11660 {
11661 2088281 int32_t tempy=yofs;
11662 2088281 flip = 0;
11663 2088281 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
11664
11665
2/2
✓ Branch 0 taken 667695 times.
✓ Branch 1 taken 1420586 times.
2088281 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
11666
2/2
✓ Branch 0 taken 690563 times.
✓ Branch 1 taken 1397718 times.
2088281 if(!get_qr(qr_ENEMIESZAXIS))
11667 {
11668 1397718 yofs+=int32_t(step/zslongToFix(dstep*10));
11669 1397718 }
11670
11671
6/6
✓ Branch 0 taken 2067591 times.
✓ Branch 1 taken 20690 times.
✓ Branch 2 taken 676820 times.
✓ Branch 3 taken 1390771 times.
✓ Branch 4 taken 661452 times.
✓ Branch 5 taken 15368 times.
2088281 if(!shadow_overpit(this) && (!get_qr(qr_ENEMIESZAXIS) || step > 0))
11672 2052223 enemy::drawshadow(dest, translucent);
11673 2088281 yofs=tempy;
11674 2088281 }
11675
11676 7949863 void eKeese::draw(BITMAP *dest)
11677 {
11678 7949863 update_enemy_frame();
11679 7949863 enemy::draw(dest);
11680 7949863 }
11681
11682 13720 void eKeese::init_size_flags()
11683 {
11684 13720 SIZEflags = d->SIZEflags;
11685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_X_OFFSET)) hxofs = 2;
11686
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
11687
11688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_WIDTH)) hit_width = 12;
11689
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
11690
11691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_Y_OFFSET)) hyofs = 4;
11692
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
11693
11694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_HEIGHT)) hit_height = 8;
11695
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
11696
11697
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13720 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11698 // al_trace("Enemy txsz:%i\n", txsz);
11699
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13720 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
11700
11701
11702
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
11703
11704
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
11705
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
11706 {
11707 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11708 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
11709 }
11710
11711
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
11712 13720 }
11713
11714 20171 void eWizzrobe::submerge(bool set)
11715 {
11716
2/2
✓ Branch 0 taken 20024 times.
✓ Branch 1 taken 147 times.
20171 if(get_qr(qr_OLD_WIZZROBE_SUBMERGING))
11717 {
11718 20024 hxofs = set?1000:0;
11719 20024 return;
11720 }
11721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if(submerged == set) return;
11722 147 submerged = set;
11723
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 71 times.
147 if(set)
11724 76 hxofs+=1000;
11725 71 else hxofs -= 1000;
11726 20171 }
11727 5350 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11728 5350 {
11729 5350 hxofs = 0;
11730 5350 submerged = false;
11731
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2992 times.
5350 switch(dmisc1)
11732 {
11733 case 0:
11734 2992 submerge(true);
11735 2992 fading=fade_invisible;
11736 // Set clk to just before the 'reappear' threshold
11737
9/10
✓ Branch 0 taken 2991 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2991 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1184 times.
✓ Branch 5 taken 1808 times.
✓ Branch 6 taken 1184 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1807 times.
✓ Branch 9 taken 1 times.
2992 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
11738 2992 break;
11739
11740 default:
11741 2358 dir=(loadside==right)?right:left;
11742 2358 misc=-3;
11743 2358 break;
11744 }
11745
11746 //netst+2880;
11747 5350 charging=false;
11748 5350 firing=false;
11749 5350 fclk=0;
11750
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2992 times.
5350 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
11751
1/4
✓ Branch 0 taken 5350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5350 if (SIZEflags != 0) init_size_flags();;
11752 5350 }
11753
11754 2081613 bool eWizzrobe::animate(int32_t index)
11755 {
11756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2081613 times.
2081613 if(switch_hooked) return enemy::animate(index);
11757
2/4
✓ Branch 0 taken 2081613 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2081613 times.
2081613 if(fallclk||drownclk) return enemy::animate(index);
11758
2/2
✓ Branch 0 taken 38023 times.
✓ Branch 1 taken 2043590 times.
2081613 if(dying)
11759 {
11760 38023 return Dead(index);
11761 }
11762
11763
2/2
✓ Branch 0 taken 1976944 times.
✓ Branch 1 taken 66646 times.
2043590 if(clk==0)
11764 {
11765 66646 removearmos(x,y,ffcactivated);
11766 66646 }
11767
11768
2/2
✓ Branch 0 taken 1019220 times.
✓ Branch 1 taken 1024370 times.
2043590 if(dmisc1) // Floating
11769 {
11770 1019220 wizzrobe_attack();
11771 1019220 }
11772 else // Teleporting
11773 {
11774
5/6
✓ Branch 0 taken 1017286 times.
✓ Branch 1 taken 7084 times.
✓ Branch 2 taken 11087 times.
✓ Branch 3 taken 1006199 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11087 times.
1024370 if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
11775 {
11776 7084 fading=0;
11777 7084 submerge(false);
11778 7084 solid_update(false);
11779 7084 }
11780
8/8
✓ Branch 0 taken 983365 times.
✓ Branch 1 taken 6240 times.
✓ Branch 2 taken 5313 times.
✓ Branch 3 taken 5151 times.
✓ Branch 4 taken 5006 times.
✓ Branch 5 taken 4247 times.
✓ Branch 6 taken 4109 times.
✓ Branch 7 taken 3855 times.
1017286 else switch(clk)
11781 {
11782 case 0:
11783
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 5123 times.
6240 if(!dmisc2)
11784 {
11785 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
11786 // but should not appear on dungeon walls.
11787
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 4710 times.
5123 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
11788
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 4486 times.
4710 else if (editorflags&ENEMY_FLAG5)
11789 {
11790 //2.10 Windrobe
11791 //randomise location and face Hero
11792 224 int32_t t=0;
11793 224 bool placed=false;
11794
11795
4/4
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 367 times.
✓ Branch 3 taken 224 times.
591 while(!placed && t<160)
11796 {
11797
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 87 times.
367 if(isdungeon(screen_spawned))
11798 {
11799 280 x=((zc_oldrand()%12)+2)*16;
11800 280 y=((zc_oldrand()%7)+2)*16;
11801 280 }
11802 else
11803 {
11804 87 x=((zc_oldrand()%14)+1)*16;
11805 87 y=((zc_oldrand()%9)+1)*16;
11806 }
11807
11808 367 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11809
11810
6/6
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 224 times.
611 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11811 {
11812 224 placed=true;
11813 224 }
11814
11815 367 ++t;
11816 }
11817
11818
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 163 times.
224 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11819 {
11820
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 14 times.
61 if(y<Hero.getY())
11821 {
11822 47 dir=down;
11823 47 }
11824 else
11825 {
11826 14 dir=up;
11827 }
11828 61 }
11829 else
11830 {
11831
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 72 times.
163 if(x<Hero.getX())
11832 {
11833 72 dir=right;
11834 72 }
11835 else
11836 {
11837 91 dir=left;
11838 }
11839 }
11840
11841
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 if(!placed) // can't place him, he's gone
11842 return true;
11843
11844
11845 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
11846 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
11847 224 }
11848 4486 else place_on_axis(true, dmisc4!=0);
11849 5123 }
11850 else
11851 {
11852 1117 int32_t t=0;
11853 1117 bool placed=false;
11854
11855
4/4
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 2443 times.
✓ Branch 2 taken 2443 times.
✓ Branch 3 taken 1117 times.
3560 while(!placed && t<160)
11856 {
11857
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 1103 times.
2443 if(isdungeon(screen_spawned))
11858 {
11859 1340 x=((zc_oldrand()%12)+2)*16;
11860 1340 y=((zc_oldrand()%7)+2)*16;
11861 1340 }
11862 else
11863 {
11864 1103 x=((zc_oldrand()%14)+1)*16;
11865 1103 y=((zc_oldrand()%9)+1)*16;
11866 }
11867
11868 2443 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11869
11870
6/6
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 1313 times.
✓ Branch 2 taken 898 times.
✓ Branch 3 taken 415 times.
✓ Branch 4 taken 1326 times.
✓ Branch 5 taken 1117 times.
3756 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11871 {
11872 1117 placed=true;
11873 1117 }
11874
11875 2443 ++t;
11876 }
11877
11878
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 731 times.
1117 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11879 {
11880
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 148 times.
386 if(y<Hero.getY())
11881 {
11882 238 dir=down;
11883 238 }
11884 else
11885 {
11886 148 dir=up;
11887 }
11888 386 }
11889 else
11890 {
11891
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 391 times.
731 if(x<Hero.getX())
11892 {
11893 340 dir=right;
11894 340 }
11895 else
11896 {
11897 391 dir=left;
11898 }
11899 }
11900
11901
1/2
✓ Branch 0 taken 1117 times.
✗ Branch 1 not taken.
1117 if(!placed) // can't place him, he's gone
11902 return true;
11903 }
11904
11905 6240 fading=fade_flicker;
11906 6240 submerge(false);
11907 6240 solid_update(false);
11908 6240 break;
11909
11910 case 64:
11911 5313 fading=0;
11912 5313 charging=true;
11913 5313 break;
11914
11915 case 73:
11916 5151 charging=false;
11917 5151 firing=40;
11918 5151 break;
11919
11920 case 83:
11921 5006 wizzrobe_attack_for_real();
11922 5006 break;
11923
11924 case 119:
11925 4247 firing=false;
11926 4247 charging=true;
11927 4247 break;
11928
11929 case 128:
11930 4109 fading=fade_flicker;
11931 4109 charging=false;
11932 4109 break;
11933
11934 case 146:
11935 3855 fading=fade_invisible;
11936 3855 submerge(true);
11937 3855 solid_update(false);
11938
11939 [[fallthrough]];
11940 default:
11941
4/4
✓ Branch 0 taken 987060 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 980971 times.
✓ Branch 3 taken 6249 times.
987220 if(clk>=(146+zc_max(0,dmisc5)))
11942 6249 clk=-1;
11943
11944 987220 break;
11945 }
11946 }
11947
11948 2043590 return enemy::animate(index);
11949 2081613 }
11950
11951 7929 void eWizzrobe::wizzrobe_attack_for_real()
11952 {
11953
1/2
✓ Branch 0 taken 7929 times.
✗ Branch 1 not taken.
7929 if(wpn==0) // Edited enemies
11954 return;
11955
11956
2/2
✓ Branch 0 taken 1983 times.
✓ Branch 1 taken 5946 times.
7929 if(dmisc2 == 0) //normal weapon
11957 {
11958 5946 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
11959 5946 sfx(firesfx, pan(x));
11960 5946 }
11961
2/2
✓ Branch 0 taken 995 times.
✓ Branch 1 taken 988 times.
1983 else if(dmisc2 == 1) // ring of fire
11962 {
11963 995 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
11964 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11965 995 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
11966 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11967 995 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
11968 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11969 995 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
11970 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11971 995 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
11972 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11973 995 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
11974 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11975 995 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
11976 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11977 995 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
11978 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11979 //this block of code was buggy and flat out doesn't match the default wpnsfx for these weapons.
11980 //i've compromised by making all old quest use this code chunk by default.
11981
1/2
✓ Branch 0 taken 995 times.
✗ Branch 1 not taken.
995 if (FFCore.quest_format[vGuys] < 51)
11982 {
11983 995 sfx(WAV_FIRE, pan(x));
11984
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 507 times.
995 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) sfx(WAV_FIRE,pan(x));
11985 else
11986 {
11987
3/17
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 68 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 420 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
507 switch (wpn)
11988 {
11989 19 case ewFireball: sfx(40, pan(x)); break;
11990 case ewBrang: sfx(4, pan(x)); break; //Ghost.zh has 0?
11991 case ewSword: sfx(20, pan(x)); break; //Ghost.zh has 0?
11992 case ewRock: sfx(51, pan(x)); break;
11993 68 case ewMagic: sfx(32, pan(x)); break;
11994 case ewBomb: sfx(3, pan(x)); break; //Ghost.zh has 0?
11995 case ewSBomb: sfx(3, pan(x)); break; //Ghost.zh has 0?
11996 case ewLitBomb: sfx(21, pan(x)); break; //Ghost.zh has 0?
11997 case ewLitSBomb: sfx(21, pan(x)); break; //Ghost.zh has 0?
11998 case ewFireTrail: sfx(13, pan(x)); break;
11999 420 case ewFlame: sfx(13, pan(x)); break;
12000 case ewWind: sfx(32, pan(x)); break;
12001 case ewFlame2: sfx(13, pan(x)); break;
12002 case ewFlame2Trail: sfx(13, pan(x)); break;
12003 case ewIce: sfx(44, pan(x)); break;
12004 case ewFireball2: sfx(40, pan(x)); break; //fireball (rising)
12005 default: sfx(WAV_FIRE, pan(x)); break;
12006 }
12007 }
12008 995 }
12009 else
12010 {
12011 sfx(firesfx, pan(x));
12012 }
12013 995 }
12014
2/2
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 17 times.
988 else if(dmisc2==2) // summons specific enemy
12015 {
12016 971 int32_t bc=0;
12017
12018
2/2
✓ Branch 0 taken 10497 times.
✓ Branch 1 taken 971 times.
11468 for(int32_t gc=0; gc<guys.Count(); gc++)
12019 {
12020
2/2
✓ Branch 0 taken 5302 times.
✓ Branch 1 taken 5195 times.
10497 if((((enemy*)guys.spr(gc))->id) == dmisc3)
12021 {
12022 5195 ++bc;
12023 5195 }
12024 10497 }
12025
12026
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 963 times.
971 if(bc<=40)
12027 {
12028 963 int32_t kids = guys.Count();
12029 963 int32_t bats=(zc_oldrand()%3)+1;
12030
12031
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 963 times.
2928 for(int32_t i=0; i<bats; i++)
12032 {
12033 // Summon bats (or anything)
12034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if(addchild(screen_spawned, x,y,dmisc3,-10, this))
12035 1965 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12036 1965 }
12037 963 sfx(firesfx, pan(x));
12038 963 }
12039 971 }
12040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 else if(dmisc2==3) //summon from layer
12041 {
12042
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(count_layer_enemies(screen_spawned)==0)
12043 {
12044 return;
12045 }
12046
12047 17 int32_t kids = guys.Count();
12048
12049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(kids<200)
12050 {
12051 17 int32_t newguys=(zc_oldrand()%3)+1;
12052 17 bool summoned=false;
12053
12054
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 17 times.
49 for(int32_t i=0; i<newguys; i++)
12055 {
12056 32 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
12057 32 int32_t x2=0;
12058 32 int32_t y2=0;
12059
12060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 for(int32_t k=0; k<20; ++k)
12061 {
12062 36 x2=16*((zc_oldrand()%12)+2);
12063 36 y2=16*((zc_oldrand()%7)+2);
12064
12065
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 32 times.
72 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
12066 {
12067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this))
12068 {
12069 32 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12070
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
32 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
12071 {
12072 ((enemy*)guys.spr(kids+i))->fakez = 64;
12073 ((enemy*)guys.spr(kids+i))->z = 0;
12074 }
12075 32 }
12076
12077 32 summoned=true;
12078 32 break;
12079 }
12080 4 }
12081 32 }
12082
12083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(summoned)
12084 {
12085 17 sfx(firesfx, pan(x));
12086 17 }
12087 17 }
12088 17 }
12089 7929 }
12090
12091
12092 1019220 void eWizzrobe::wizzrobe_attack()
12093 {
12094
10/12
✓ Branch 0 taken 982487 times.
✓ Branch 1 taken 36733 times.
✓ Branch 2 taken 982487 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 937882 times.
✓ Branch 5 taken 44605 times.
✓ Branch 6 taken 934499 times.
✓ Branch 7 taken 3383 times.
✓ Branch 8 taken 932879 times.
✓ Branch 9 taken 1620 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 932879 times.
1019220 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
12095 86341 return;
12096
12097
3/8
✓ Branch 0 taken 893341 times.
✓ Branch 1 taken 39538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 893341 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
932879 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
12098 {
12099 39538 fix_coords();
12100
12101
5/5
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 1050 times.
✓ Branch 2 taken 16081 times.
✓ Branch 3 taken 13008 times.
✓ Branch 4 taken 3903 times.
39538 switch(misc)
12102 {
12103 case 1: //walking
12104
2/2
✓ Branch 0 taken 10364 times.
✓ Branch 1 taken 2644 times.
13008 if(!m_walkflag(x,y,spw_door, dir))
12105 2644 misc=0;
12106 else
12107 {
12108 10364 clk3=16;
12109
12110
2/2
✓ Branch 0 taken 8966 times.
✓ Branch 1 taken 1398 times.
10364 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
12111 {
12112 1398 wizzrobe_newdir(0);
12113 1398 }
12114 }
12115
12116 13008 break;
12117
12118 case 2: //phasing
12119 {
12120 3903 int32_t jx=x;
12121 3903 int32_t jy=y;
12122 3903 int32_t jdir=-1;
12123
12124
5/5
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 484 times.
✓ Branch 2 taken 472 times.
✓ Branch 3 taken 482 times.
✓ Branch 4 taken 492 times.
3903 switch(zc_oldrand()&7)
12125 {
12126 case 0:
12127 484 jx-=32;
12128 484 jy-=32;
12129 484 jdir=15;
12130 484 break;
12131
12132 case 1:
12133 472 jx+=32;
12134 472 jy-=32;
12135 472 jdir=9;
12136 472 break;
12137
12138 case 2:
12139 482 jx+=32;
12140 482 jy+=32;
12141 482 jdir=11;
12142 482 break;
12143
12144 case 3:
12145 492 jx-=32;
12146 492 jy+=32;
12147 492 jdir=13;
12148 492 break;
12149 }
12150
12151
10/10
✓ Branch 0 taken 1930 times.
✓ Branch 1 taken 1973 times.
✓ Branch 2 taken 1724 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 1597 times.
✓ Branch 5 taken 127 times.
✓ Branch 6 taken 1385 times.
✓ Branch 7 taken 212 times.
✓ Branch 8 taken 1140 times.
✓ Branch 9 taken 245 times.
3903 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
12152 {
12153 1140 misc=3;
12154 1140 clk3=32;
12155 1140 dir=jdir;
12156 1140 break;
12157 }
12158 2763 }
12159 [[fallthrough]];
12160 case 3:
12161 3813 dir&=3;
12162 3813 misc=0;
12163 [[fallthrough]];
12164 case 0:
12165 19894 wizzrobe_newdir(64);
12166 [[fallthrough]];
12167 default:
12168
2/2
✓ Branch 0 taken 21886 times.
✓ Branch 1 taken 3504 times.
25390 if(!canmove(dir,(zfix)1,spw_door,false))
12169 {
12170
2/2
✓ Branch 0 taken 3265 times.
✓ Branch 1 taken 239 times.
3504 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
12171 {
12172 3265 misc=1;
12173 3265 clk3=16;
12174 3265 }
12175 else
12176 {
12177 239 wizzrobe_newdir(64);
12178 239 misc=0;
12179 239 clk3=32;
12180 }
12181 3504 }
12182 else
12183 {
12184 21886 clk3=32;
12185 }
12186
12187 25390 break;
12188 }
12189
12190
2/2
✓ Branch 0 taken 35060 times.
✓ Branch 1 taken 4478 times.
39538 if(misc<0)
12191 4478 ++misc;
12192 39538 }
12193
12194 932879 --clk3;
12195
12196
3/3
✓ Branch 0 taken 248377 times.
✓ Branch 1 taken 620599 times.
✓ Branch 2 taken 63903 times.
932879 switch(misc)
12197 {
12198 case 1:
12199 case 3:
12200 248377 step=1;
12201 248377 break;
12202
12203 case 2:
12204 63903 step=0;
12205 63903 break;
12206
12207 default:
12208 620599 step=0.5;
12209 620599 break;
12210
12211 }
12212
12213 932879 move(step);
12214
12215 // if(d->misc1 && misc<=0 && clk3==28)
12216
5/6
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620599 times.
✓ Branch 3 taken 312280 times.
✓ Branch 4 taken 599052 times.
✓ Branch 5 taken 21547 times.
932879 if(dmisc1 && misc<=0 && clk3==28)
12217 {
12218
2/2
✓ Branch 0 taken 16835 times.
✓ Branch 1 taken 4712 times.
21547 if(dmisc2 != 1)
12219 {
12220
2/2
✓ Branch 0 taken 14907 times.
✓ Branch 1 taken 1928 times.
16835 if(lined_up(8,false) == dir)
12221 {
12222 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
12223 // sfx(WAV_WAND,pan(x));
12224 1928 wizzrobe_attack_for_real();
12225 1928 fclk=30;
12226 1928 }
12227 16835 }
12228 else
12229 {
12230
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 995 times.
4712 if((zc_oldrand()%500)>=400)
12231 {
12232 995 wizzrobe_attack_for_real();
12233 995 fclk=30;
12234 995 }
12235 }
12236 21547 }
12237
12238
4/4
✓ Branch 0 taken 517526 times.
✓ Branch 1 taken 415353 times.
✓ Branch 2 taken 4050 times.
✓ Branch 3 taken 513476 times.
932879 if(misc==0 && (zc_oldrand()&127)==0)
12239 4050 misc=2;
12240
12241
4/4
✓ Branch 0 taken 67953 times.
✓ Branch 1 taken 864926 times.
✓ Branch 2 taken 64512 times.
✓ Branch 3 taken 3441 times.
932879 if(misc==2 && clk3==4)
12242 3441 fix_coords();
12243
12244
2/4
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 932879 times.
932879 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
12245 {
12246
2/2
✓ Branch 0 taken 849597 times.
✓ Branch 1 taken 83282 times.
932879 if(fclk>0)
12247 {
12248 83282 --fclk;
12249 83282 }
12250 932879 }
12251
12252 1019220 }
12253
12254 21531 void eWizzrobe::wizzrobe_newdir(int32_t homing)
12255 {
12256 // Wizzrobes shouldn't move to the edge of the screen;
12257 // if they're already there, they should move toward the center
12258
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 21498 times.
21531 if(x<32)
12259 33 dir=right;
12260
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 21494 times.
21498 else if(x>=world_w-32)
12261 4 dir=left;
12262
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21492 times.
21494 else if(y<32)
12263 2 dir=down;
12264
2/2
✓ Branch 0 taken 21487 times.
✓ Branch 1 taken 5 times.
21492 else if(y>=world_h-32)
12265 5 dir=up;
12266 else
12267 21487 newdir(4,homing,spw_wizzrobe);
12268 21531 }
12269
12270 2099229 void eWizzrobe::draw(BITMAP *dest)
12271 {
12272 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
12273
13/14
✓ Branch 0 taken 1042483 times.
✓ Branch 1 taken 1056746 times.
✓ Branch 2 taken 817873 times.
✓ Branch 3 taken 224610 times.
✓ Branch 4 taken 132112 times.
✓ Branch 5 taken 910371 times.
✓ Branch 6 taken 130752 times.
✓ Branch 7 taken 1360 times.
✓ Branch 8 taken 129926 times.
✓ Branch 9 taken 826 times.
✓ Branch 10 taken 125018 times.
✓ Branch 11 taken 4908 times.
✓ Branch 12 taken 125018 times.
✗ Branch 13 not taken.
2099229 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
12274 125018 return;
12275
12276 1974211 int32_t tempint=dummy_int[1];
12277 1974211 bool tempbool1=dummy_bool[1];
12278 1974211 bool tempbool2=dummy_bool[2];
12279 1974211 dummy_int[1]=fclk;
12280 1974211 dummy_bool[1]=charging;
12281 1974211 dummy_bool[2]=firing;
12282 1974211 update_enemy_frame();
12283 1974211 dummy_int[1]=tempint;
12284 1974211 dummy_bool[1]=tempbool1;
12285 1974211 dummy_bool[2]=tempbool2;
12286 1974211 enemy::draw(dest);
12287 2099229 }
12288
12289 203 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12290 203 {
12291 203 fading=fade_flash_die;
12292
6/8
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 154 times.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 46 times.
203 if(dir==down&&y>=128)
12293 {
12294 3 dir=up;
12295 3 }
12296
12297
5/8
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 141 times.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 62 times.
203 if(dir==right&&x>=208)
12298 {
12299 dir=left;
12300 }
12301
1/4
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203 if (SIZEflags != 0) init_size_flags();;
12302 203 }
12303
12304 125855 bool eDodongo::animate(int32_t index)
12305 {
12306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125855 times.
125855 if(switch_hooked) return enemy::animate(index);
12307
2/2
✓ Branch 0 taken 3790 times.
✓ Branch 1 taken 122065 times.
125855 if(dying)
12308 {
12309 3790 return Dead(index);
12310 }
12311
12312
2/2
✓ Branch 0 taken 121496 times.
✓ Branch 1 taken 569 times.
122065 if(clk==0)
12313 {
12314 569 removearmos(x,y,ffcactivated);
12315 569 }
12316
12317
2/2
✓ Branch 0 taken 10848 times.
✓ Branch 1 taken 111217 times.
122065 if(clk2) // ate a bomb
12318 {
12319
2/2
✓ Branch 0 taken 10735 times.
✓ Branch 1 taken 113 times.
10848 if(--clk2==0)
12320 113 hp-=misc; // store bomb's power in misc
12321 10848 }
12322 else
12323 111217 constant_walk(rate,homing,spw_clipright);
12324
12325 122065 hit_width = (dir<=down) ? 16 : 32;
12326 // hysz = (dir>=left) ? 16 : 32;
12327
12328 122065 return enemy::animate(index);
12329 125855 }
12330
12331 125845 void eDodongo::draw(BITMAP *dest)
12332 {
12333 125845 tile=o_tile;
12334
12335
2/2
✓ Branch 0 taken 3065 times.
✓ Branch 1 taken 122780 times.
125845 if(clk<0)
12336 {
12337 3065 enemy::drawzcboss(dest);
12338 3065 return;
12339 }
12340
12341 122780 update_enemy_frame();
12342 122780 enemy::drawzcboss(dest);
12343
12344
2/2
✓ Branch 0 taken 51662 times.
✓ Branch 1 taken 71118 times.
122780 if(dummy_int[1]!=0) //additional tiles
12345 {
12346 71118 tile+=dummy_int[1]; //second tile is previous tile
12347 71118 xofs-=16; //new xofs change
12348 71118 enemy::drawzcboss(dest);
12349 71118 xofs+=16;
12350 71118 }
12351
12352 125845 }
12353
12354 8218 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
12355 {
12356 8218 int32_t wpnId = w->id;
12357 8218 int32_t power = w->power;
12358 8218 int32_t wpnx = w->x;
12359 8218 int32_t wpny = w->y;
12360
12361
5/12
✓ Branch 0 taken 8218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8218 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2457 times.
✓ Branch 5 taken 5761 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2457 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8218 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
12362 5761 return 0;
12363
12364
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 803 times.
✓ Branch 2 taken 1491 times.
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 146 times.
2457 switch(wpnId)
12365 {
12366 case wPhantom:
12367 return 0;
12368
12369 case wFire:
12370 case wBait:
12371 case wWhistle:
12372 case wWind:
12373 case wSSparkle:
12374 case wFSparkle:
12375 return 0;
12376
12377 case wLitBomb:
12378 case wLitSBomb:
12379
6/6
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 537 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 510 times.
✓ Branch 4 taken 690 times.
✓ Branch 5 taken 113 times.
803 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
12380 690 return 0;
12381
12382 113 clk2=96;
12383 113 misc=power;
12384
12385
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 3 times.
113 if(wpnId==wLitSBomb)
12386 3 item_set=isSBOMB100;
12387
12388 113 return 1;
12389
12390 case wBomb:
12391 case wSBomb:
12392
6/6
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 1064 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 1071 times.
✓ Branch 4 taken 516 times.
✓ Branch 5 taken 975 times.
1491 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
12393 516 return 0;
12394
12395 975 stunclk=160;
12396 975 misc=wpnId; // store wpnId
12397 975 return 1;
12398
12399 case wSword:
12400
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 88 times.
146 if(stunclk)
12401 {
12402 88 sfx(WAV_EHIT,pan(x));
12403 88 hp=0;
12404 88 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12405 88 fading=0; // don't flash
12406 88 return 1;
12407 }
12408
12409 [[fallthrough]];
12410 default:
12411 75 sfx(WAV_CHINK,pan(x));
12412 75 }
12413
12414 75 return 1;
12415 8218 }
12416
12417 48 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12418 48 {
12419 48 fading=fade_flash_die;
12420 //nets+5180;
12421 48 previous_dir=-1;
12422
6/8
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 13 times.
48 if(dir==down&&y>=128)
12423 {
12424 1 dir=up;
12425 1 }
12426
12427
5/8
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
48 if(dir==right&&x>=208)
12428 {
12429 dir=left;
12430 }
12431
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if (SIZEflags != 0) init_size_flags();;
12432 48 }
12433
12434 39398 bool eDodongo2::animate(int32_t index)
12435 {
12436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39398 times.
39398 if(switch_hooked) return enemy::animate(index);
12437
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 38240 times.
39398 if(dying)
12438 {
12439 1158 return Dead(index);
12440 }
12441
12442
2/2
✓ Branch 0 taken 38073 times.
✓ Branch 1 taken 167 times.
38240 if(clk==0)
12443 {
12444 167 removearmos(x,y,ffcactivated);
12445 167 }
12446
12447
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 34208 times.
38240 if(clk2) // ate a bomb
12448 {
12449
2/2
✓ Branch 0 taken 3990 times.
✓ Branch 1 taken 42 times.
4032 if(--clk2==0)
12450 42 hp-=misc; // store bomb's power in misc
12451 4032 }
12452 else
12453 34208 constant_walk(rate,homing,spw_clipbottomright);
12454
12455 38240 hit_width = (dir<=down) ? 16 : 32;
12456 38240 hit_height = (dir>=left) ? 16 : 32;
12457 38240 hxofs=(dir>=left)?-8:0;
12458 38240 hyofs=(dir<left)?-8:0;
12459
12460 38240 return enemy::animate(index);
12461 39398 }
12462
12463 39601 void eDodongo2::draw(BITMAP *dest)
12464 {
12465
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 38833 times.
39601 if(clk<0)
12466 {
12467 768 enemy::drawzcboss(dest);
12468 768 return;
12469 }
12470
12471 38833 int32_t tempx=xofs;
12472 38833 int32_t tempy=yofs;
12473 38833 update_enemy_frame();
12474 38833 enemy::drawzcboss(dest);
12475 38833 tile+=dummy_int[1]; //second tile change
12476 38833 xofs+=dummy_int[2]; //new xofs change
12477 38833 yofs+=dummy_int[3]; //new yofs change
12478 38833 enemy::drawzcboss(dest);
12479 38833 xofs=tempx;
12480 38833 yofs=tempy;
12481 39601 }
12482
12483 3929 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
12484 {
12485 3929 int32_t wpnId = w->id;
12486 3929 int32_t power = w->power;
12487 3929 int32_t wpnx = w->x;
12488 3929 int32_t wpny = w->y;
12489
12490
5/8
✓ Branch 0 taken 3929 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3929 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1552 times.
✓ Branch 5 taken 2377 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1552 times.
3929 if(dying || clk<0 || clk2>0 || superman)
12491 2377 return 0;
12492
12493
5/6
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 161 times.
1552 switch(wpnId)
12494 {
12495 case wPhantom:
12496 return 0;
12497
12498 case wFire:
12499 case wBait:
12500 case wWhistle:
12501 case wWind:
12502 case wSSparkle:
12503 case wFSparkle:
12504 346 return 0;
12505
12506 case wLitBomb:
12507 case wLitSBomb:
12508
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 81 times.
321 switch(dir)
12509 {
12510 case up:
12511
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 4 times.
81 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12512 77 return 0;
12513
12514 4 break;
12515
12516 case down:
12517
4/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 6 times.
77 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12518 71 return 0;
12519
12520 6 break;
12521
12522 case left:
12523
4/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 16 times.
82 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12524 66 return 0;
12525
12526 16 break;
12527
12528 case right:
12529
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 16 times.
81 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12530 65 return 0;
12531
12532 16 break;
12533 }
12534
12535 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
12536 // return 0;
12537 42 clk2=96;
12538 42 misc=power;
12539
12540
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(wpnId==wLitSBomb)
12541 item_set=isSBOMB100;
12542
12543 42 return 1;
12544
12545 case wBomb:
12546 case wSBomb:
12547
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 185 times.
✓ Branch 4 taken 164 times.
693 switch(dir)
12548 {
12549 case up:
12550
4/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 92 times.
176 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12551 84 return 0;
12552
12553 92 break;
12554
12555 case down:
12556
4/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 55 times.
168 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12557 113 return 0;
12558
12559 55 break;
12560
12561 case left:
12562
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 105 times.
185 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12563 80 return 0;
12564
12565 105 break;
12566
12567 case right:
12568
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 93 times.
164 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12569 71 return 0;
12570
12571 93 break;
12572 }
12573
12574 345 stunclk=160;
12575 345 misc=wpnId; // store wpnId
12576 345 return 1;
12577
12578 case wSword:
12579
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 34 times.
161 if(stunclk)
12580 {
12581 34 sfx(WAV_EHIT,pan(x));
12582 34 hp=0;
12583 34 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12584 34 fading=0; // don't flash
12585 34 return 1;
12586 }
12587
12588 [[fallthrough]];
12589 default:
12590 158 sfx(WAV_CHINK,pan(x));
12591 158 }
12592
12593 158 return 1;
12594 3929 }
12595
12596 126 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
12597 126 {
12598 //these are here to bypass compiler warnings about unused arguments
12599
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if ( !(editorflags & ENEMY_FLAG5) )
12600 {
12601
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 position_relative_to_screen(x, y, dmisc1 ? 64 : 176, 64);
12602 126 }
12603 else { x = X; y = Y; }
12604
12605 //nets+5940;
12606
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 45 times.
126 if(get_qr(qr_NEWENEMYTILES))
12607 {
12608 81 }
12609 else
12610 {
12611
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 7 times.
45 if(dmisc1)
12612 {
12613 7 flip=1;
12614 7 }
12615 }
12616
12617
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12618 126 clk3=32;
12619 126 clk2=0;
12620 126 clk4=clk;
12621 126 dir=left;
12622
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if (SIZEflags != 0) init_size_flags();;
12623 126 }
12624
12625 71899 bool eAquamentus::animate(int32_t index)
12626 {
12627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71899 times.
71899 if(switch_hooked) return enemy::animate(index);
12628
2/2
✓ Branch 0 taken 2092 times.
✓ Branch 1 taken 69807 times.
71899 if(dying)
12629 2092 return Dead(index);
12630
12631 // fbx=x+((id==eRAQUAM)?4:-4);
12632
2/2
✓ Branch 0 taken 69490 times.
✓ Branch 1 taken 317 times.
69807 if(clk==0)
12633 {
12634 317 removearmos(x,y,ffcactivated);
12635 317 }
12636
12637 69807 fbx=x;
12638
12639 /*
12640 if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM)
12641 {
12642 fbx+=16;
12643 }
12644 */
12645
2/2
✓ Branch 0 taken 69357 times.
✓ Branch 1 taken 450 times.
69807 if(--clk3==0)
12646 {
12647 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
12648 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
12649 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
12650 450 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
12651 450 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
12652 450 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
12653 450 sfx(wpnsfx(wpn),pan(x));
12654 450 }
12655
12656
4/4
✓ Branch 0 taken 21363 times.
✓ Branch 1 taken 48444 times.
✓ Branch 2 taken 21018 times.
✓ Branch 3 taken 345 times.
69807 if(clk3<-80 && !(zc_oldrand()&63))
12657 {
12658 345 clk3=32;
12659 345 }
12660
12661 69807 int screen_x = x.getInt()%256;
12662
2/2
✓ Branch 0 taken 68690 times.
✓ Branch 1 taken 1117 times.
69807 if(!((clk4+1)&63))
12663 {
12664 1117 int32_t d2=(zc_oldrand()%3)+1;
12665
12666
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 752 times.
1117 if(d2>=left)
12667 {
12668 752 dir=d2;
12669 752 }
12670
12671
2/2
✓ Branch 0 taken 732 times.
✓ Branch 1 taken 385 times.
1117 if(dmisc1)
12672 {
12673
2/2
✓ Branch 0 taken 347 times.
✓ Branch 1 taken 38 times.
385 if(screen_x<=40)
12674 {
12675 38 dir=right;
12676 38 }
12677
12678
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 if(screen_x>=104)
12679 {
12680 dir=left;
12681 }
12682 385 }
12683 else
12684 {
12685
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 21 times.
732 if(screen_x<=136)
12686 {
12687 21 dir=right;
12688 21 }
12689
12690
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 34 times.
732 if(screen_x>=200)
12691 {
12692 34 dir=left;
12693 34 }
12694 }
12695 1117 }
12696
12697
4/4
✓ Branch 0 taken 67907 times.
✓ Branch 1 taken 1900 times.
✓ Branch 2 taken 59366 times.
✓ Branch 3 taken 8541 times.
69807 if(clk4>=-1 && !((clk4+1)&7))
12698 {
12699
2/2
✓ Branch 0 taken 4546 times.
✓ Branch 1 taken 3995 times.
8541 if(dir==left)
12700 {
12701 4546 x-=1;
12702 4546 }
12703 else
12704 {
12705 3995 x+=1;
12706 }
12707 8541 }
12708
12709 69807 clk4=(clk4+1)%256;
12710
12711 69807 return enemy::animate(index);
12712 71899 }
12713
12714 72310 void eAquamentus::draw(BITMAP *dest)
12715 {
12716
2/2
✓ Branch 0 taken 44994 times.
✓ Branch 1 taken 27316 times.
72310 if(get_qr(qr_NEWENEMYTILES))
12717 {
12718 44994 xofs=(dmisc1?-16:0);
12719
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44994 times.
✓ Branch 2 taken 18341 times.
✓ Branch 3 taken 26653 times.
44994 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
12720
12721
2/2
✓ Branch 0 taken 1312 times.
✓ Branch 1 taken 43682 times.
44994 if(dying)
12722 {
12723 1312 xofs=0;
12724 1312 enemy::draw(dest);
12725 1312 }
12726 else
12727 {
12728 43682 drawblock(dest,15);
12729 }
12730 44994 }
12731 else
12732 {
12733 27316 int32_t xblockofs=((dmisc1)?-16:16);
12734 27316 xofs=0;
12735
12736
4/4
✓ Branch 0 taken 26634 times.
✓ Branch 1 taken 682 times.
✓ Branch 2 taken 780 times.
✓ Branch 3 taken 25854 times.
27316 if(clk<0 || dying)
12737 {
12738 1462 enemy::draw(dest);
12739 1462 return;
12740 }
12741
1/2
✓ Branch 0 taken 25854 times.
✗ Branch 1 not taken.
25854 if ( do_animation )
12742 {
12743 // face (0=firing, 2=resting)
12744 25854 tile=o_tile+((clk3>0)?0:2);
12745 25854 enemy::draw(dest);
12746 // tail (
12747 25854 tile=o_tile+((clk&16)?1:3);
12748 25854 xofs=xblockofs;
12749 25854 enemy::draw(dest);
12750 // body
12751 25854 yofs+=16;
12752 25854 xofs=0;
12753 25854 tile=o_tile+((clk&16)?20:22);
12754 25854 enemy::draw(dest);
12755 25854 xofs=xblockofs;
12756 25854 tile=o_tile+((clk&16)?21:23);
12757 25854 enemy::draw(dest);
12758 25854 yofs-=16;
12759 25854 }
12760 else enemy::draw(dest);
12761 }
12762 72310 }
12763
12764 23834 bool eAquamentus::hit(weapon *w)
12765 {
12766
3/6
✓ Branch 0 taken 23834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23834 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23834 times.
23834 if(!w->scriptcoldet || w->fallclk || w->drownclk) return false;
12767
12768
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 19633 times.
23834 switch(w->id)
12769 {
12770 case wBeam:
12771 case wRefBeam:
12772 case wMagic:
12773 4201 hit_height=32;
12774 4201 }
12775
12776
4/4
✓ Branch 0 taken 22740 times.
✓ Branch 1 taken 1094 times.
✓ Branch 2 taken 17546 times.
✓ Branch 3 taken 5194 times.
23834 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
12777 23834 hit_height=16;
12778 23834 return ret;
12779
12780 23834 }
12781
12782 93 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
12783 93 {
12784
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if ( !(editorflags & ENEMY_FLAG5) )
12785 {
12786
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 position_relative_to_screen(x, y, 128, 48);
12787 93 }
12788 else { x = X; y = Y; }
12789
12790 93 Clk=Clk;
12791
2/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 if(flags & guy_fade_flicker)
12792 {
12793 clk=0;
12794 superman = 1;
12795 fading=fade_flicker;
12796 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12797 }
12798
3/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 42 times.
93 else if(flags & guy_fade_instant)
12799 {
12800 42 clk=0;
12801 42 }
12802 93 hxofs=-16;
12803 93 hit_width=48;
12804 93 clk4=0;
12805
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12806
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 dir=zc_oldrand()%3+1;
12807
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if (SIZEflags != 0) init_size_flags();;
12808
12809 //nets+5340;
12810 93 }
12811
12812 70891 bool eGohma::animate(int32_t index)
12813 {
12814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70891 times.
70891 if(switch_hooked) return enemy::animate(index);
12815
2/2
✓ Branch 0 taken 1226 times.
✓ Branch 1 taken 69665 times.
70891 if(dying)
12816 1226 return Dead(index);
12817
12818
2/2
✓ Branch 0 taken 69629 times.
✓ Branch 1 taken 36 times.
69665 if(fading)
12819 {
12820
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1 times.
36 if(++clk4 > 60)
12821 {
12822 35 clk4=0;
12823 35 superman=0;
12824 35 fading=0;
12825 35 clk=0;
12826
12827 35 }
12828 1 else return enemy::animate(index);
12829 35 }
12830
12831
2/2
✓ Branch 0 taken 69314 times.
✓ Branch 1 taken 350 times.
69664 if(clk==0)
12832 {
12833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 if (ffcactivated) removearmosffc(*ffcactivated);
12834 else
12835 {
12836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 removearmos(zc_max(x-16, 0_zf),y);
12837 350 did_armos = false;
12838 350 removearmos(x,y);
12839 350 did_armos = false;
12840
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 removearmos(zc_min(x+16, 255_zf),y);
12841 }
12842 350 }
12843
12844
2/2
✓ Branch 0 taken 68878 times.
✓ Branch 1 taken 786 times.
69664 if(clk<0) return enemy::animate(index);
12845
12846 // Movement clk must be separate from animation clk because of the Clock item
12847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68878 times.
68878 if(!watch)
12848 68878 clk4++;
12849
12850
2/2
✓ Branch 0 taken 67846 times.
✓ Branch 1 taken 1032 times.
68878 if((clk4&63)==0)
12851 {
12852
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 486 times.
1032 if(clk4&64)
12853 546 dir^=1;
12854 else
12855 486 dir=zc_oldrand()%3+1;
12856 1032 }
12857
12858
2/2
✓ Branch 0 taken 67761 times.
✓ Branch 1 taken 1117 times.
68878 if((clk&63)==3)
12859 {
12860
2/2
✓ Branch 0 taken 882 times.
✓ Branch 1 taken 235 times.
1117 switch(dmisc1)
12861 {
12862 case 1:
12863 235 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
12864 235 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12865 235 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
12866 235 sfx(wpnsfx(wpn),pan(x));
12867 235 break;
12868
12869 default:
12870
3/4
✓ Branch 0 taken 882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 754 times.
882 if(dmisc1 != 1 && dmisc1 != 2)
12871 {
12872 754 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12873 754 sfx(wpnsfx(wpn),pan(x));
12874 754 sfx(wpnsfx(wpn),pan(x));
12875 754 }
12876
12877 882 break;
12878 }
12879 1117 }
12880
12881
6/6
✓ Branch 0 taken 8027 times.
✓ Branch 1 taken 60851 times.
✓ Branch 2 taken 7611 times.
✓ Branch 3 taken 416 times.
✓ Branch 4 taken 5396 times.
✓ Branch 5 taken 2215 times.
68878 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
12882 {
12883
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 1925 times.
2215 if(!(clk3%8))
12884 {
12885 290 FireBreath(true);
12886 290 }
12887 2215 }
12888
12889
2/2
✓ Branch 0 taken 34399 times.
✓ Branch 1 taken 34479 times.
68878 if(clk4&1)
12890 34479 move((zfix)1);
12891
12892
2/2
✓ Branch 0 taken 68728 times.
✓ Branch 1 taken 150 times.
68878 if(++clk3>=400)
12893 150 clk3=0;
12894
12895 68878 return enemy::animate(index);
12896 70891 }
12897
12898 70889 void eGohma::draw(BITMAP *dest)
12899 {
12900 70889 tile=o_tile;
12901
12902
4/4
✓ Branch 0 taken 70103 times.
✓ Branch 1 taken 786 times.
✓ Branch 2 taken 1226 times.
✓ Branch 3 taken 68877 times.
70889 if(clk<0 || dying)
12903 {
12904 2012 enemy::drawzcboss(dest);
12905 2012 return;
12906 }
12907
12908
2/2
✓ Branch 0 taken 53472 times.
✓ Branch 1 taken 15405 times.
68877 if(get_qr(qr_NEWENEMYTILES))
12909 {
12910 ///if ( do_animation )
12911 //Yuck. Gohma can just not have this capability right now.
12912 // left side
12913 53472 xofs=-16;
12914 53472 flip=0;
12915 // if(clk&16) tile=180;
12916 // else { tile=182; flip=1; }
12917 53472 tile+=(3*((clk&48)>>4));
12918 53472 enemy::drawzcboss(dest);
12919
12920 // right side
12921 53472 xofs=16;
12922 // tile=(180+182)-tile;
12923 53472 tile=o_tile;
12924 53472 tile+=(3*((clk&48)>>4))+2;
12925 53472 enemy::drawzcboss(dest);
12926
12927 // body
12928 53472 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
12929 53472 tile=o_tile;
12930
12931 // tile+=(3*((clk&24)>>3))+2;
12932
2/2
✓ Branch 0 taken 2975 times.
✓ Branch 1 taken 50497 times.
53472 if(clk3<16)
12933 2975 tile+=7;
12934
2/2
✓ Branch 0 taken 15890 times.
✓ Branch 1 taken 34607 times.
50497 else if(clk3<116)
12935 15890 tile+=10;
12936
2/2
✓ Branch 0 taken 2051 times.
✓ Branch 1 taken 32556 times.
34607 else if(clk3<132)
12937 2051 tile+=7;
12938 else
12939 32556 tile+=((clk3-132)&24)?4:1;
12940
12941 53472 enemy::drawzcboss(dest);
12942
12943 53472 }
12944 else
12945 {
12946 // left side
12947 15405 xofs=-16;
12948 15405 flip=0;
12949
12950
2/2
✓ Branch 0 taken 7615 times.
✓ Branch 1 taken 7790 times.
15405 if(!(clk&16))
12951 {
12952 7790 tile+=2;
12953 7790 flip=1;
12954 7790 }
12955
12956 15405 enemy::draw(dest);
12957
12958 // right side
12959 15405 tile=o_tile;
12960 15405 xofs=16;
12961
12962
2/2
✓ Branch 0 taken 7790 times.
✓ Branch 1 taken 7615 times.
15405 if((clk&16)) tile+=2;
12963
12964 // tile=(180+182)-tile;
12965 15405 enemy::draw(dest);
12966
12967 // body
12968 15405 tile=o_tile;
12969 15405 xofs=0;
12970
12971
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 14493 times.
15405 if(clk3<16)
12972 912 tile+=4;
12973
2/2
✓ Branch 0 taken 4882 times.
✓ Branch 1 taken 9611 times.
14493 else if(clk3<116)
12974 4882 tile+=5;
12975
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 9026 times.
9611 else if(clk3<132)
12976 585 tile+=4;
12977 9026 else tile+=((clk3-132)&8)?3:1;
12978
12979 15405 enemy::draw(dest);
12980
12981 }
12982 70889 }
12983
12984 578 int32_t eGohma::takehit(weapon *w, weapon* realweap)
12985 {
12986 578 int32_t wpnId = w->id;
12987 578 int32_t power = w->power;
12988 578 int32_t wpnx = w->x;
12989 578 int32_t wpnDir = w->dir;
12990 578 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
12991
12992
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 421 times.
578 if(def < 0)
12993 {
12994
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 367 times.
✓ Branch 5 taken 54 times.
✓ Branch 6 taken 364 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 36 times.
421 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
12995 {
12996 93 sfx(WAV_CHINK,pan(x));
12997 93 return 1;
12998 }
12999 328 }
13000
13001 485 return enemy::takehit(w, realweap);
13002 578 }
13003
13004 327 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13005 327 {
13006 327 count_enemy=(id==(id&0xFFF));
13007 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
13008
1/4
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327 if (SIZEflags != 0) init_size_flags();;
13009 327 }
13010
13011 124050 bool eLilDig::animate(int32_t index)
13012 {
13013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124050 times.
124050 if(switch_hooked) return enemy::animate(index);
13014
2/2
✓ Branch 0 taken 4410 times.
✓ Branch 1 taken 119640 times.
124050 if(dying)
13015 4410 return Dead(index);
13016
13017
2/2
✓ Branch 0 taken 7105 times.
✓ Branch 1 taken 112535 times.
119640 if(clk==0)
13018 {
13019 7105 removearmos(x,y,ffcactivated);
13020 7105 }
13021
13022
2/2
✓ Branch 0 taken 80994 times.
✓ Branch 1 taken 38646 times.
119640 if(misc<=128)
13023 {
13024
2/2
✓ Branch 0 taken 1161 times.
✓ Branch 1 taken 37485 times.
38646 if(!(++misc&31))
13025 1161 step+=0.25;
13026 38646 }
13027
13028 119640 variable_walk_8(rate,homing,hrate,spw_floater);
13029 119640 return enemy::animate(index);
13030 124050 }
13031
13032 124268 void eLilDig::draw(BITMAP *dest)
13033 {
13034 124268 tile = o_tile;
13035 // tile = 160;
13036 124268 int32_t fdiv = frate/4;
13037
1/2
✓ Branch 0 taken 124268 times.
✗ Branch 1 not taken.
124268 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13038
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13039 124268 efrate:((clk>=(frate>>1))?1:0);
13040
13041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124268 times.
124268 if ( do_animation )
13042 {
13043
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 if(get_qr(qr_NEWENEMYTILES))
13044 {
13045
9/9
✓ Branch 0 taken 11370 times.
✓ Branch 1 taken 10699 times.
✓ Branch 2 taken 10722 times.
✓ Branch 3 taken 12015 times.
✓ Branch 4 taken 10070 times.
✓ Branch 5 taken 9554 times.
✓ Branch 6 taken 8255 times.
✓ Branch 7 taken 10033 times.
✓ Branch 8 taken 8739 times.
91457 switch(dir-8) //directions get screwed up after 8. *shrug*
13046 {
13047 case up: //u
13048 11370 flip=0;
13049 11370 break;
13050
13051 case l_up: //d
13052 10699 flip=0;
13053 10699 tile+=4;
13054 10699 break;
13055
13056 case l_down: //l
13057 10722 flip=0;
13058 10722 tile+=8;
13059 10722 break;
13060
13061 case left: //r
13062 12015 flip=0;
13063 12015 tile+=12;
13064 12015 break;
13065
13066 case r_down: //ul
13067 10070 flip=0;
13068 10070 tile+=20;
13069 10070 break;
13070
13071 case down: //ur
13072 9554 flip=0;
13073 9554 tile+=24;
13074 9554 break;
13075
13076 case r_up: //dl
13077 8255 flip=0;
13078 8255 tile+=28;
13079 8255 break;
13080
13081 case right: //dr
13082 10033 flip=0;
13083 10033 tile+=32;
13084 10033 break;
13085 }
13086
13087 91457 tile+=f2;
13088 91457 }
13089 else
13090 {
13091 32811 tile+=(clk>=6)?1:0;
13092 }
13093 124268 }
13094
13095 124268 enemy::draw(dest);
13096 124268 }
13097
13098 80 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13099 80 {
13100
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 init_size_flags();
13101 80 }
13102
13103 29662 bool eBigDig::animate(int32_t index)
13104 {
13105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(switch_hooked) return enemy::animate(index);
13106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(dying)
13107 return Dead(index);
13108
13109
2/2
✓ Branch 0 taken 25558 times.
✓ Branch 1 taken 4104 times.
29662 if(clk==0)
13110 {
13111 4104 removearmos(x,y,ffcactivated);
13112 4104 }
13113
13114
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29534 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
29662 switch(misc)
13115 {
13116 case 0:
13117 29534 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
13118 29534 break;
13119
13120 case 1:
13121 64 ++misc;
13122 64 break;
13123
13124 case 2:
13125
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 64 times.
175 for(int32_t i=0; i<dmisc5; i++)
13126 {
13127 111 addenemy(screen_spawned,x,y,dmisc1+0x1000,-15);
13128 111 }
13129
13130
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc6; i++)
13131 {
13132 30 addenemy(screen_spawned,x,y,dmisc2+0x1000,-15);
13133 30 }
13134
13135
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc7; i++)
13136 {
13137 30 addenemy(screen_spawned,x,y,dmisc3+0x1000,-15);
13138 30 }
13139
13140
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc8; i++)
13141 {
13142 30 addenemy(screen_spawned,x,y,dmisc4+0x1000,-15);
13143 30 }
13144
13145
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
64 if(itemguy) // Hand down the carried item
13146 {
13147 2 int guycarryingitem = guys.Count()-1;
13148 2 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13149 2 itemguy = false;
13150 2 }
13151
13152 64 stop_bgsfx(index);
13153
13154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(deadsfx > 0) sfx(deadsfx,pan(x));
13155
13156 64 return true;
13157 }
13158
13159 29598 return enemy::animate(index);
13160 29662 }
13161
13162 29658 void eBigDig::draw(BITMAP *dest)
13163 {
13164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if(anim!=aDIG)
13165 {
13166 update_enemy_frame();
13167 xofs-=8;
13168 yofs-=8;
13169 drawblock(dest,15);
13170 xofs+=8;
13171 yofs+=8;
13172 return;
13173 }
13174
13175 29658 tile = o_tile;
13176 29658 int32_t fdiv = frate/4;
13177
1/2
✓ Branch 0 taken 29658 times.
✗ Branch 1 not taken.
29658 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13178
13179
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13180 29658 efrate:((clk>=(frate>>1))?1:0);
13181
13182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if ( do_animation )
13183 {
13184
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 if(get_qr(qr_NEWENEMYTILES))
13185 {
13186
9/9
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 1684 times.
✓ Branch 2 taken 2031 times.
✓ Branch 3 taken 1910 times.
✓ Branch 4 taken 2041 times.
✓ Branch 5 taken 2043 times.
✓ Branch 6 taken 1514 times.
✓ Branch 7 taken 1009 times.
✓ Branch 8 taken 2241 times.
16161 switch(dir-8) //directions get screwed up after 8. *shrug*
13187 {
13188 case up: //u
13189 1688 flip=0;
13190 1688 break;
13191
13192 case l_up: //d
13193 1684 flip=0;
13194 1684 tile+=8;
13195 1684 break;
13196
13197 case l_down: //l
13198 2031 flip=0;
13199 2031 tile+=40;
13200 2031 break;
13201
13202 case left: //r
13203 1910 flip=0;
13204 1910 tile+=48;
13205 1910 break;
13206
13207 case r_down: //ul
13208 2041 flip=0;
13209 2041 tile+=80;
13210 2041 break;
13211
13212 case down: //ur
13213 2043 flip=0;
13214 2043 tile+=88;
13215
13216 2043 break;
13217
13218 case r_up: //dl
13219 1514 flip=0;
13220 1514 tile+=120;
13221 1514 break;
13222
13223 case right: //dr
13224 2241 flip=0;
13225 2241 tile+=128;
13226 2241 break;
13227 }
13228
13229 16161 tile+=(f2*2);
13230 16161 }
13231 else
13232 {
13233 13497 tile+=(f2)?0:2;
13234 13497 flip=(clk&1)?1:0;
13235 }
13236 29658 }
13237
13238 29658 xofs-=8;
13239 29658 yofs-=8;
13240 29658 drawblock(dest,15);
13241 29658 xofs+=8;
13242 29658 yofs+=8;
13243 29658 }
13244
13245 869 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
13246 {
13247 869 int32_t wpnId = w->id;
13248
13249
3/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 805 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
869 if(wpnId==wWhistle && misc==0)
13250 {
13251 64 misc = 1;
13252 64 w->hit_pierce(this, 0, false);
13253 64 }
13254
13255 869 return 0;
13256 }
13257
13258 80 void eBigDig::init_size_flags()
13259 {
13260 80 SIZEflags = d->SIZEflags;
13261
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13262 // al_trace("Enemy txsz:%i\n", txsz);
13263
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
13264
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
13265 80 else hit_width = 32;
13266
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
13267 80 else hit_height = 32;
13268
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
13269 80 else hzsz = 16; // hard to jump.
13270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
13271 80 else hxofs = -8;
13272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
13273 80 else hyofs = -8;
13274 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13275
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = d->xofs;
13276
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
13277 {
13278 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13279 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
13280 }
13281
13282
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = d->zofs;
13283 80 }
13284
13285 13 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13286 13 {
13287 13 hxofs=hyofs=8;
13288
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (editorflags & ENEMY_FLAG3)
13289 {
13290 hxofs = 4;
13291 hyofs = 4;
13292 hit_width = 24;
13293 hit_height = 24;
13294 SIZEflags|=OVERRIDE_HIT_WIDTH;
13295 SIZEflags|=OVERRIDE_HIT_HEIGHT;
13296 }
13297 13 hzsz=16; //can't be jumped.
13298 13 clk2=70;
13299 13 misc=-1;
13300
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 mapscr* scr = get_scr(screen_spawned);
13301
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 mainguy=(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN));
13302 13 }
13303
13304 18254 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
13305 {
13306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18254 times.
18254 if(dying)
13307
13308 return Dead(index);
13309
13310
2/2
✓ Branch 0 taken 18182 times.
✓ Branch 1 taken 72 times.
18254 if(clk==0)
13311 {
13312 72 removearmos(x,y,ffcactivated);
13313 72 }
13314
13315
6/7
✓ Branch 0 taken 3607 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12680 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 984 times.
✓ Branch 5 taken 960 times.
✓ Branch 6 taken 10 times.
18254 switch(misc)
13316 {
13317 case -1:
13318 13 misc=0;
13319 [[fallthrough]];
13320 case 0:
13321
4/4
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 11985 times.
✓ Branch 2 taken 535 times.
✓ Branch 3 taken 173 times.
12693 if(++clk2>72 && !(zc_oldrand()&3))
13322 {
13323 173 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
13324 173 sfx(wpnsfx(wpn),pan(x));
13325 173 clk2=0;
13326 173 }
13327
13328 12693 Stunclk=0;
13329 12693 constant_walk(rate,homing,spw_none);
13330 12693 break;
13331
13332 case 1:
13333 case 2:
13334
2/2
✓ Branch 0 taken 3566 times.
✓ Branch 1 taken 41 times.
3607 if(--Stunclk<=0)
13335 {
13336 41 int32_t r=zc_oldrand();
13337
13338
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 17 times.
41 if(r&1)
13339 {
13340 17 y=96;
13341
13342
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 11 times.
17 if(r&2)
13343 6 x=160;
13344 else
13345 11 x=48;
13346
13347
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
17 if(tooclose(x,y,48))
13348 8 x=208-x;
13349
13350 17 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
13351 17 }
13352
13353 41 loadpalset(csBOSS,pSprite(d->bosspal));
13354 41 misc=0;
13355 41 }
13356
13357 3607 break;
13358
13359 case 3:
13360 {
13361
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 12 times.
984 if(hclk>0)
13362 972 break;
13363
13364 12 misc=4;
13365 12 clk=0;
13366 12 hxofs=1000;
13367 12 loadpalset(9,pSprite(spPILE));
13368 12 music_stop();
13369 12 stop_sfx(WAV_ROAR);
13370
13371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(deadsfx>0) sfx(deadsfx,pan(x));
13372
13373 12 sfx(WAV_GANON);
13374 //Ganon's dustpile; fall in sideview. -Z
13375 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13376 //dustpile->miscellaneous[31] = eeGANON;
13377
6/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
12 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13378 12 item *dustpile = NULL;
13379 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
13380 12 dustpile = (item *)items.spr(items.Count() - 1);
13381 12 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
13382 12 break;
13383 }
13384
13385 case 4:
13386
2/2
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 12 times.
960 if(clk>=80)
13387 {
13388 12 misc=5;
13389
13390 //game->lvlitems[dlevel]|=liBOSS;
13391
13392 12 sfx(WAV_CLEARED);
13393 //Add the big TF over the ashes!
13394
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
36 for(word q = 0; q < items.Count(); q++)
13395 {
13396 24 item *ashes = (item*)items.spr(q);
13397
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 12 times.
24 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
13398 {
13399 //Z_scripterrlog("Found correct dustpile!\n");
13400
4/8
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
12 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
13401 12 item *bigtriforce = NULL;
13402 12 bigtriforce = (item *)items.spr(items.Count() - 1);
13403 12 bigtriforce->linked_parent = eeGANON;
13404 12 }
13405 24 }
13406 12 }
13407
13408 960 break;
13409 10 case 5: return true;
13410 }
13411
13412 18244 return enemy::animate(index);
13413 18254 }
13414
13415
13416 964 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13417 {
13418 //these are here to bypass compiler warnings about unused arguments
13419 964 int32_t wpnId = w->id;
13420 964 int32_t power = w->power;
13421 964 int32_t enemyHitWeapon = w->parentitem;
13422
13423
3/3
✓ Branch 0 taken 714 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 166 times.
964 switch(misc)
13424 {
13425 case 0:
13426
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 53 times.
84 if(wpnId!=wSword)
13427 31 return 0;
13428
13429 53 hp-=power;
13430
13431
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 12 times.
53 if(hp>0)
13432 {
13433 41 misc=1;
13434 41 Stunclk=64;
13435 41 }
13436 else
13437 {
13438 12 loadpalset(csBOSS,pSprite(spBROWN));
13439 12 misc=2;
13440 12 Stunclk=284;
13441 12 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13442 }
13443
13444 53 sfx(WAV_EHIT,pan(x));
13445
13446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(hitsfx>0) sfx(hitsfx,pan(x));
13447
13448 53 return 1;
13449
13450 case 2:
13451
4/6
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
166 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
13452 154 return 0;
13453
13454 12 misc=3;
13455 12 hclk=81;
13456 12 loadpalset(9,pSprite(spBROWN));
13457 12 return 1;
13458 }
13459
13460 714 return 0;
13461 964 }
13462
13463 20776 void eGanon::draw(BITMAP *dest)
13464 {
13465
6/6
✓ Branch 0 taken 3608 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 983 times.
✓ Branch 3 taken 2535 times.
✓ Branch 4 taken 12680 times.
✓ Branch 5 taken 960 times.
20776 switch(misc)
13466 {
13467 case 0:
13468
2/2
✓ Branch 0 taken 9511 times.
✓ Branch 1 taken 3169 times.
12680 if((clk&3)==3)
13469 3169 tile=(zc_oldrand()%5)*2+o_tile;
13470
13471
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
13472 {
13473
13474 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13475 {
13476 int odraw = drawstyle;
13477 drawstyle = 2;
13478 drawblock(dest,15);
13479 drawstyle = odraw;
13480 }
13481 else
13482 {
13483 drawblock(dest,15);
13484 }
13485 break;
13486
13487 }
13488
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
13489 {
13490 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13491 {
13492 int odraw = drawstyle;
13493 drawstyle = 2;
13494 drawblock(dest,15);
13495 drawstyle = odraw;
13496 }
13497 else
13498 {
13499 drawblock(dest,15);
13500 }
13501 break;
13502 }
13503
1/2
✓ Branch 0 taken 12680 times.
✗ Branch 1 not taken.
12680 if(db!=999)
13504 12680 break;
13505 [[fallthrough]];
13506 case 2:
13507
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 983 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
983 if(Stunclk<64 && (Stunclk&1))
13508 break;
13509 [[fallthrough]];
13510 case -1:
13511 3518 tile=o_tile;
13512
13513 [[fallthrough]];
13514 case 1:
13515 case 3:
13516 7126 drawblock(dest,15);
13517 7126 break;
13518
13519 case 4:
13520 960 draw_guts(dest);
13521 960 draw_flash(dest);
13522 960 break;
13523 }
13524 20776 }
13525
13526 960 void eGanon::draw_guts(BITMAP *dest)
13527 {
13528
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 204 times.
960 int32_t c = zc_min(clk>>3,8);
13529 960 tile = clk<24 ? 74 : 75;
13530 960 overtile16(dest,tile,x+8-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13531 960 overtile16(dest,tile,x+8-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13532 960 overtile16(dest,tile,x+c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13533 960 overtile16(dest,tile,x+16-c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13534 960 overtile16(dest,tile,x+c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13535 960 overtile16(dest,tile,x+16-c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13536 960 overtile16(dest,tile,x+c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13537 960 overtile16(dest,tile,x+16-c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13538 960 }
13539
13540 960 void eGanon::draw_flash(BITMAP *dest)
13541 {
13542
13543 960 int32_t c = clk-(clk>>2);
13544 960 cs = (frame&3)+6;
13545 960 overtile16(dest,194,x+8-viewport.x,y+8-clk+playing_field_offset-viewport.y,cs,0);
13546 960 overtile16(dest,194,x+8-viewport.x,y+8+clk+playing_field_offset-viewport.y,cs,2);
13547 960 overtile16(dest,195,x+8-clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,0);
13548 960 overtile16(dest,195,x+8+clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,1);
13549 960 overtile16(dest,196,x+8-c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,0);
13550 960 overtile16(dest,196,x+8+c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,1);
13551 960 overtile16(dest,196,x+8-c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,2);
13552 960 overtile16(dest,196,x+8+c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,3);
13553 960 }
13554
13555 15 void getBigTri(mapscr* scr, int32_t id2)
13556 {
13557 /*
13558 *************************
13559 * BIG TRIFORCE SEQUENCE *
13560 *************************
13561 0 BIGTRI out, WHITE flash in
13562 4 WHITE flash out, PILE cset white
13563 8 WHITE in
13564 ...
13565 188 WHITE out
13566 191 PILE cset red
13567 200 top SHUTTER opens
13568 209 bottom SHUTTER opens
13569 */
13570 15 sfx(itemsbuf[id2].playsound);
13571 15 guys.clear();
13572
13573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(itemsbuf[id2].flags & item_gamedata)
13574 {
13575 game->lvlitems[dlevel]|=liTRIFORCE;
13576 }
13577
13578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
13579
13580 15 draw_screen();
13581
13582
4/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2880 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 2880 times.
2895 for(int32_t f=0; f<24*8 && !Quit; f++)
13583 {
13584
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==4)
13585 {
13586
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 15 times.
240 for(int32_t i=1; i<16; i++)
13587 {
13588 225 RAMpal[CSET(9)+i]=_RGB(255,255,255);
13589 225 }
13590 15 }
13591
13592
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==0)
13593 {
13594
2/2
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 360 times.
1440 for(int32_t cs=2; cs<5; cs++)
13595 {
13596
2/2
✓ Branch 0 taken 16200 times.
✓ Branch 1 taken 1080 times.
17280 for(int32_t i=1; i<16; i++)
13597 {
13598 16200 RAMpal[CSET(cs)+i]=_RGB(255,255,255);
13599 16200 }
13600 1080 }
13601
13602 360 refreshpal=true;
13603 360 }
13604
13605
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==4)
13606 {
13607
1/2
✓ Branch 0 taken 360 times.
✗ Branch 1 not taken.
360 if(cur_screen<128) loadlvlpal(DMaps[cur_dmap].color);
13608 else loadlvlpal(0xB);
13609 360 }
13610
13611
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==191)
13612 {
13613 15 loadpalset(9,pSprite(spPILE));
13614 15 }
13615
13616 2880 advanceframe(true);
13617 2880 }
13618
13619 //play_DmapMusic();
13620 15 playLevelMusic();
13621
13622
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
15 if(itemsbuf[id2].flags & item_flag1 && cur_screen < 128)
13623 {
13624 2 Hero.dowarp(hero_scr, 1, 0); //side warp
13625 2 }
13626 15 }
13627
13628 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
13629 618 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13630 618 {
13631
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if( !(editorflags & ENEMY_FLAG5) )
13632 {
13633
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 position_relative_to_screen(x, y, 128, 48);
13634 618 }
13635 //else { x = X; y = Y; }
13636
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 dir=(zc_oldrand()&7)+8;
13637 618 superman=1;
13638 618 fading=fade_invisible;
13639 618 hxofs=1000;
13640 618 segcnt=clk;
13641 618 segid=Id|0x1000;
13642 618 clk=0;
13643
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 id=guys.Count();
13644
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
618 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13645 618 tile=o_tile;
13646 618 hitdir = -1;
13647 618 stickclk = 0;
13648
13649 /*
13650 if (get_qr(qr_NEWENEMYTILES))
13651 {
13652 tile=nets+1220;
13653 }
13654 else
13655 {
13656 tile=57;
13657 }
13658 */
13659 618 }
13660
13661 244844 bool eMoldorm::animate(int32_t index)
13662 {
13663 244844 update_current_screen();
13664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(switch_hooked) return enemy::animate(index);
13665 244844 int32_t max_y = isdungeon(screen_spawned) ? 100 : 100+28; //warning: Ugly hack. -Z
13666
2/2
✓ Branch 0 taken 216369 times.
✓ Branch 1 taken 28475 times.
244844 if ( y > (max_y) )
13667 {
13668 28475 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
13669 //Z_scripterrlog("Stickclk is %d\n", stickclk);
13670 28475 }
13671
2/2
✓ Branch 0 taken 244282 times.
✓ Branch 1 taken 562 times.
244844 if ( stickclk > 45 )
13672 {
13673 562 stickclk = 0;
13674 562 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
13675 562 }
13676
13677
13678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(clk==0)
13679 {
13680 244844 removearmos(x,y,ffcactivated);
13681 244844 }
13682
13683
2/2
✓ Branch 0 taken 2451 times.
✓ Branch 1 taken 242393 times.
244844 if(clk2)
13684 {
13685
2/2
✓ Branch 0 taken 2322 times.
✓ Branch 1 taken 129 times.
2451 if(--clk2 == 0)
13686 {
13687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(flags&guy_never_return)
13688 129 never_return(screen_spawned, index);
13689
13690
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
13691 129 leave_item();
13692
13693 129 stop_bgsfx(index);
13694 129 return true;
13695 }
13696 2322 }
13697 else
13698 {
13699
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(stunclk>0)
13700 stunclk=0;
13701 242393 constant_walk_8_old(rate,homing,spw_floater);
13702
13703
13704 242393 misc=dir;
13705
13706 // If any higher-numbered segments were killed, segcnt can be too high,
13707 // leading to a crash
13708
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(index+segcnt>=guys.Count())
13709 segcnt=guys.Count()-index-1;
13710
13711
2/2
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 1122281 times.
1364674 for(int32_t i=index+1; i<index+segcnt+1; i++)
13712 {
13713 1122281 enemy* segment=((enemy*)guys.spr(i));
13714
13715 // More validation - if segcnt was wrong, this may not
13716 // actually be a Moldorm segment
13717
1/2
✓ Branch 0 taken 1122281 times.
✗ Branch 1 not taken.
1122281 if(segment->id!=segid)
13718 {
13719 segcnt=i-index-1;
13720 break;
13721 }
13722
13723
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1)
13724 {
13725 242669 x=segment->x;
13726 242669 y=segment->y;
13727 242669 }
13728
13729 1122281 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
13730 //Script your own blasted segmented bosses!! -Z
13731 1122281 segment->setParent(this);
13732
4/4
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 879888 times.
✓ Branch 2 taken 24660 times.
✓ Branch 3 taken 217733 times.
1122281 if((i==index+segcnt)&&(i!=index+1)) //tail
13733 {
13734 217733 segment->dummy_int[1]=2;
13735 217733 }
13736 else
13737 {
13738 904548 segment->dummy_int[1]=1;
13739 }
13740
13741
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1) //head
13742 {
13743 242669 segment->dummy_int[1]=0;
13744 242669 }
13745
13746
2/2
✓ Branch 0 taken 1121265 times.
✓ Branch 1 taken 1016 times.
1122281 if(segment->hp <= 0)
13747 {
13748 1016 int32_t offset=1;
13749
13750
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 1480 times.
2496 for(int32_t j=i; j<index+segcnt; j++)
13751 {
13752 // Triple-check
13753
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(((enemy*)guys.spr(j+1))->id!=segid)
13754 {
13755 segcnt=j-index+1; // Add 1 because of --segcnt below
13756 break;
13757 }
13758 1480 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
13759 1480 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
13760 1480 }
13761
13762 1016 segment->hclk=33;
13763 1016 --segcnt;
13764 1016 --i; // Recheck the same index in case multiple segments died at once
13765 1016 }
13766 1122281 }
13767
13768
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 242264 times.
242393 if(segcnt==0)
13769 {
13770 129 clk2=19;
13771
13772 129 x=guys.spr(index+1)->x;
13773 129 y=guys.spr(index+1)->y;
13774 129 }
13775 }
13776
13777 244715 return false;
13778 244844 }
13779
13780 3150 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13781 3150 {
13782
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 if( !(editorflags & ENEMY_FLAG5) )
13783 {
13784
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 position_relative_to_screen(x, y, 128, 48);
13785 3150 }
13786
13787
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3150 times.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13788 3150 hyofs=4;
13789 3150 hit_width=hit_height=8;
13790 3150 hxofs=1000;
13791 3150 mainguy=count_enemy=false;
13792 3150 parentclk = 0;
13793 3150 bgsfx=-1;
13794
2/4
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 flags&=~guy_never_return;
13795 //deadsfx = WAV_EDEAD;
13796 3150 isCore = false;
13797 3150 }
13798
13799 1138024 bool esMoldorm::animate(int32_t index)
13800 {
13801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(switch_hooked) return enemy::animate(index);
13802 // Shouldn't be possible, but better to be sure
13803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(index==0)
13804 dying=true;
13805
13806
2/2
✓ Branch 0 taken 15743 times.
✓ Branch 1 taken 1122281 times.
1138024 if(dying)
13807 {
13808
1/2
✓ Branch 0 taken 15743 times.
✗ Branch 1 not taken.
15743 if(!dmisc2)
13809 15743 item_set=0;
13810
13811 15743 return Dead(index);
13812 }
13813
13814
2/2
✓ Branch 0 taken 105077 times.
✓ Branch 1 taken 1017204 times.
1122281 if(clk>=0)
13815 {
13816 1017204 hxofs=4;
13817 1017204 step=((enemy*)guys.spr(index-1))->step;
13818
13819
2/2
✓ Branch 0 taken 70455 times.
✓ Branch 1 taken 946749 times.
1017204 if(parentclk == 0)
13820 {
13821 70455 misc=dir;
13822 70455 dir=((enemy*)guys.spr(index-1))->misc;
13823 //do alignment, as in parent's animation :-/ -DD
13824 70455 x.doFloor();
13825 70455 y.doFloor();
13826 70455 }
13827
13828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(step)
13829 1017204 parentclk=(parentclk+1)%((int32_t)(8.0/step));
13830
13831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(!watch)
13832 {
13833 1017204 sprite::move(step);
13834 1017204 }
13835 1017204 }
13836
13837 1122281 return enemy::animate(index);
13838 1138024 }
13839
13840 2683 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
13841 {
13842
2/2
✓ Branch 0 taken 2230 times.
✓ Branch 1 taken 453 times.
2683 if(enemy::takehit(w,realweap))
13843 2230 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
13844
13845 453 return 0;
13846 2683 }
13847
13848 1155313 void esMoldorm::draw(BITMAP *dest)
13849 {
13850 1155313 tile=o_tile;
13851 1155313 int32_t fdiv = frate/4;
13852
1/2
✓ Branch 0 taken 1155313 times.
✗ Branch 1 not taken.
1155313 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13853
13854
2/2
✓ Branch 0 taken 1043930 times.
✓ Branch 1 taken 111383 times.
1155313 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13855 1155313 efrate:((clk>=(frate>>1))?1:0);
13856
13857
2/2
✓ Branch 0 taken 111383 times.
✓ Branch 1 taken 1043930 times.
1155313 if(get_qr(qr_NEWENEMYTILES))
13858 {
13859 1043930 tile+=dummy_int[1]*40;
13860
13861
2/2
✓ Branch 0 taken 102730 times.
✓ Branch 1 taken 941200 times.
1043930 if(dir<8)
13862 {
13863 102730 flip=0;
13864
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
13865
13866
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 if(dir>3) // Skip to the next row for diagonals
13867 tile+=4;
13868 102730 }
13869 else
13870 {
13871
8/9
✓ Branch 0 taken 96530 times.
✓ Branch 1 taken 134534 times.
✓ Branch 2 taken 113426 times.
✓ Branch 3 taken 124800 times.
✓ Branch 4 taken 101314 times.
✓ Branch 5 taken 99043 times.
✓ Branch 6 taken 131794 times.
✓ Branch 7 taken 139759 times.
✗ Branch 8 not taken.
941200 switch(dir-8) //directions get screwed up after 8. *shrug*
13872 {
13873 case up: //u
13874 96530 flip=0;
13875 96530 break;
13876
13877 case l_up: //d
13878 134534 flip=0;
13879 134534 tile+=4;
13880 134534 break;
13881
13882 case l_down: //l
13883 113426 flip=0;
13884 113426 tile+=8;
13885 113426 break;
13886
13887 case left: //r
13888 124800 flip=0;
13889 124800 tile+=12;
13890 124800 break;
13891
13892 case r_down: //ul
13893 101314 flip=0;
13894 101314 tile+=20;
13895 101314 break;
13896
13897 case down: //ur
13898 99043 flip=0;
13899 99043 tile+=24;
13900 99043 break;
13901
13902 case r_up: //dl
13903 131794 flip=0;
13904 131794 tile+=28;
13905 131794 break;
13906
13907 case right: //dr
13908 139759 flip=0;
13909 139759 tile+=32;
13910 139759 break;
13911 }
13912 }
13913
13914 1043930 tile+=f2;
13915 1043930 }
13916
13917
2/2
✓ Branch 0 taken 106267 times.
✓ Branch 1 taken 1049046 times.
1155313 if(clk>=0)
13918 1049046 enemy::draw(dest);
13919 1155313 }
13920
13921 420 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
13922 420 {
13923
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if( !(editorflags & ENEMY_FLAG5) )
13924 {
13925
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 position_relative_to_screen(x, y, 64, 80);
13926 420 }
13927 //else { x = X; y = Y; }
13928 //byte legaldirs = 0;
13929 420 int32_t incr = 16;
13930 //int32_t possiiblepos = 0;
13931 //int32_t positions[8] = {0};
13932
13933 //Don't spawn in pits.
13934
5/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 315 times.
✓ Branch 7 taken 105 times.
420 if ( m_walkflag_simple(x, y) )
13935 {
13936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 for ( ; incr < 240; incr += 16 )
13937 {
13938 //move if we spawn over a pit
13939 //check each direction
13940
7/12
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 139 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 139 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 135 times.
139 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
13941 {
13942
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
13943 }
13944
7/12
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 135 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 39 times.
✓ Branch 11 taken 96 times.
135 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
13945 {
13946
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 x+=incr; break;
13947 }
13948
9/16
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 96 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 96 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 96 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 64 times.
96 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
13949 {
13950
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
13951 }
13952
9/16
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 64 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 64 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 60 times.
64 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
13953 {
13954
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 x+=incr; y-=incr; break;
13955 }
13956
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
13957 {
13958 y -= incr; break;
13959 }
13960
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
13961 {
13962 y+=incr; break;
13963 }
13964
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
13965 {
13966
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
13967 }
13968
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
13969 {
13970 x+=incr; y+=incr; break;
13971 }
13972 34 else continue;
13973
13974 }
13975
13976 105 }
13977
13978 420 dir=up;
13979 420 superman=1;
13980 420 fading=fade_invisible;
13981 420 hxofs=1000;
13982 420 segcnt=clk;
13983 420 clk=0;
13984 //set up move history
13985
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 3060 times.
3480 for(int32_t i=0; i <= (1<<dmisc2); i++)
13986
3/6
✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3060 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3060 times.
✗ Branch 5 not taken.
3060 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
13987 420 }
13988
13989 236907 bool eLanmola::animate(int32_t index)
13990 {
13991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236907 times.
236907 if(switch_hooked) return enemy::animate(index);
13992
2/2
✓ Branch 0 taken 196711 times.
✓ Branch 1 taken 40196 times.
236907 if(clk==0)
13993 {
13994 40196 removearmos(x,y,ffcactivated);
13995 40196 }
13996
13997
2/2
✓ Branch 0 taken 3591 times.
✓ Branch 1 taken 233316 times.
236907 if(clk2)
13998 {
13999
2/2
✓ Branch 0 taken 3402 times.
✓ Branch 1 taken 189 times.
3591 if(--clk2 == 0)
14000 {
14001
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 103 times.
189 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
14002 86 leave_item();
14003
14004 189 stop_bgsfx(index);
14005 189 return true;
14006 }
14007
14008 3402 return false;
14009 }
14010
14011
14012 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
14013 //the direction AND x,y position of the lanmola to vary in uncertain ways.
14014 //I've added a complete movement history to this enemy to compensate -DD
14015 233316 constant_walk(rate,homing,spw_none);
14016 233316 prevState.pop_front();
14017 233316 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
14018
14019 // This could cause a crash with Moldorms. I didn't see the same problem
14020 // with Lanmolas, but it looks like it ought to be possible, so here's
14021 // the same solution. - Saf
14022
1/2
✓ Branch 0 taken 233316 times.
✗ Branch 1 not taken.
233316 if(index+segcnt>=guys.Count())
14023 segcnt=guys.Count()-index-1;
14024
14025
2/2
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 966396 times.
1199712 for(int32_t i=index+1; i<index+segcnt+1; i++)
14026 {
14027 966396 enemy* segment=((enemy*)guys.spr(i));
14028
14029 // More validation in case segcnt is wrong
14030
1/2
✓ Branch 0 taken 966396 times.
✗ Branch 1 not taken.
966396 if((segment->id&0xFFF)!=(id&0xFFF))
14031 {
14032 segcnt=i-index-1;
14033 break;
14034 }
14035
14036 966396 segment->o_tile=o_tile;
14037 966396 segment->setParent(this);
14038
4/4
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 733080 times.
✓ Branch 2 taken 37616 times.
✓ Branch 3 taken 195700 times.
966396 if((i==index+segcnt)&&(i!=index+1))
14039 {
14040 195700 segment->dummy_int[1]=1; //tail
14041 195700 }
14042 else
14043 {
14044 770696 segment->dummy_int[1]=0;
14045 }
14046
14047
2/2
✓ Branch 0 taken 965227 times.
✓ Branch 1 taken 1169 times.
966396 if(segment->hp <= 0)
14048 {
14049
2/2
✓ Branch 0 taken 1169 times.
✓ Branch 1 taken 1961 times.
3130 for(int32_t j=i; j<index+segcnt; j++)
14050 {
14051 // Triple-check
14052
1/2
✓ Branch 0 taken 1961 times.
✗ Branch 1 not taken.
1961 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
14053 {
14054 segcnt=j-index+1; // Add 1 because of --segcnt below
14055 break;
14056 }
14057 1961 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14058 1961 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14059 1961 }
14060
14061 1169 ((enemy*)guys.spr(i))->hclk=33;
14062 1169 --segcnt;
14063 1169 --i; // Recheck the same index in case multiple segments died at once
14064 1169 }
14065 966396 }
14066
14067
2/2
✓ Branch 0 taken 233127 times.
✓ Branch 1 taken 189 times.
233316 if(segcnt==0)
14068 {
14069 189 clk2=19;
14070 189 x=guys.spr(index+1)->x;
14071 189 y=guys.spr(index+1)->y;
14072 189 setmapflag(get_scr(screen_spawned), mTMPNORET);
14073 189 }
14074
14075 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
14076 //which is... disastrous.
14077 233316 hp = 1;
14078 233316 return enemy::animate(index);
14079 236907 }
14080
14081 2267 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14082 2267 {
14083
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 if( !(editorflags & ENEMY_FLAG5) )
14084 {
14085
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 position_relative_to_screen(x, y, 64, 80);
14086 2267 }
14087 2267 int32_t incr = 16;
14088 //Don't spawn in pits.
14089
5/8
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2267 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1742 times.
✓ Branch 7 taken 525 times.
2267 if ( m_walkflag_simple(x, y) )
14090 {
14091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 for ( ; incr < 240; incr += 16 )
14092 {
14093 //move if we spawn over a pit
14094 //check each direction
14095
7/12
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 695 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 695 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 695 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 695 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 675 times.
695 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14096 {
14097
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
14098 }
14099
7/12
✓ Branch 0 taken 675 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 675 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 675 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 675 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 675 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 195 times.
✓ Branch 11 taken 480 times.
675 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14100 {
14101
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 x+=incr; break;
14102 }
14103
9/16
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 480 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 480 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 480 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 480 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 480 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 320 times.
480 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14104 {
14105
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
14106 }
14107
9/16
✓ Branch 0 taken 320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 320 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 320 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 320 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 320 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 320 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 20 times.
✓ Branch 15 taken 300 times.
320 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14108 {
14109
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 x+=incr; y-=incr; break;
14110 }
14111
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14112 {
14113 y -= incr; break;
14114 }
14115
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14116 {
14117 y+=incr; break;
14118 }
14119
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14120 {
14121
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
14122 }
14123
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14124 {
14125 x+=incr; y+=incr; break;
14126 }
14127 170 else continue;
14128
14129 }
14130
14131 525 }
14132
14133 2267 hxofs=1000;
14134 2267 hit_width=8;
14135 2267 mainguy=false;
14136 2267 count_enemy=(id<0x2000)?true:false;
14137
14138 //set up move history
14139
2/2
✓ Branch 0 taken 2267 times.
✓ Branch 1 taken 16763 times.
19030 for(int32_t i=0; i <= (1<<dmisc2); i++)
14140
3/6
✓ Branch 0 taken 16763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16763 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16763 times.
✗ Branch 5 not taken.
16763 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14141
14142 2267 bgsfx = -1;
14143 2267 isCore = false;
14144
2/4
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
2267 flags&=~guy_never_return;
14145 2267 }
14146
14147 985563 bool esLanmola::animate(int32_t index)
14148 {
14149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 985563 times.
985563 if(switch_hooked) return enemy::animate(index);
14150 // Shouldn't be possible, but who knows
14151
2/2
✓ Branch 0 taken 985545 times.
✓ Branch 1 taken 18 times.
985563 if(index==0)
14152 18 dying=true;
14153
14154
2/2
✓ Branch 0 taken 19167 times.
✓ Branch 1 taken 966396 times.
985563 if(dying)
14155 {
14156 19167 xofs=0;
14157
14158
2/2
✓ Branch 0 taken 9861 times.
✓ Branch 1 taken 9306 times.
19167 if(!dmisc3)
14159 9306 item_set=0;
14160
14161 19167 return Dead(index);
14162 }
14163
14164
2/2
✓ Branch 0 taken 35946 times.
✓ Branch 1 taken 930450 times.
966396 if(clk>=0)
14165 {
14166 930450 hxofs=4;
14167
14168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 930450 times.
930450 if(!watch)
14169 {
14170 930450 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
14171 930450 prevState.pop_front();
14172 930450 prevState.push_back(newstate);
14173 930450 x = newstate.first.first;
14174 930450 y = newstate.first.second;
14175 930450 dir = newstate.second;
14176 930450 }
14177 930450 }
14178
14179 966396 return enemy::animate(index);
14180 985563 }
14181
14182 2655 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
14183 {
14184
2/2
✓ Branch 0 taken 2065 times.
✓ Branch 1 taken 590 times.
2655 if(enemy::takehit(w,realweap))
14185 2065 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14186
14187 590 return 0;
14188 2655 }
14189
14190 990931 void esLanmola::draw(BITMAP *dest)
14191 {
14192 990931 tile=o_tile;
14193 990931 int32_t fdiv = frate/4;
14194
1/2
✓ Branch 0 taken 990931 times.
✗ Branch 1 not taken.
990931 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14195
14196
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14197 990931 efrate:((clk>=(frate>>1))?1:0);
14198
14199
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 if(get_qr(qr_NEWENEMYTILES))
14200 {
14201
2/2
✓ Branch 0 taken 147165 times.
✓ Branch 1 taken 481767 times.
628932 if(id>=0x2000)
14202 {
14203 481767 tile+=20;
14204
14205
2/2
✓ Branch 0 taken 353025 times.
✓ Branch 1 taken 128742 times.
481767 if(dummy_int[1]==1)
14206 {
14207 128742 tile+=20;
14208 128742 }
14209 481767 }
14210
14211
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 141419 times.
✓ Branch 2 taken 140994 times.
✓ Branch 3 taken 159500 times.
✓ Branch 4 taken 187019 times.
628932 switch(dir)
14212 {
14213 case up:
14214 141419 flip=0;
14215 141419 break;
14216
14217 case down:
14218 140994 flip=0;
14219 140994 tile+=4;
14220 140994 break;
14221
14222 case left:
14223 159500 flip=0;
14224 159500 tile+=8;
14225 159500 break;
14226
14227 case right:
14228 187019 flip=0;
14229 187019 tile+=12;
14230 187019 break;
14231 }
14232
14233 628932 tile+=f2;
14234 628932 }
14235 else
14236 {
14237
2/2
✓ Branch 0 taken 90543 times.
✓ Branch 1 taken 271456 times.
361999 if(id>=0x2000)
14238 {
14239 271456 tile+=1;
14240 271456 }
14241 }
14242
14243
2/2
✓ Branch 0 taken 37038 times.
✓ Branch 1 taken 953893 times.
990931 if(clk>=0)
14244 953893 enemy::draw(dest);
14245 990931 }
14246
14247 150 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
14248 150 {
14249 //these are here to bypass compiler warnings about unused arguments
14250 150 Clk=Clk;
14251 150 superman=1;
14252
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 dir=(zc_oldrand()&7)+8;
14253 150 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
14254
14255
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 150 times.
842 for(int32_t i=0; i<armcnt; i++)
14256 692 arm[i]=i;
14257
14258 150 fading=fade_blue_poof;
14259 //nets+4680;
14260 150 adjusted=false;
14261
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150 if (SIZEflags != 0) init_size_flags();;
14262 150 }
14263
14264 66494 bool eManhandla::animate(int32_t index)
14265 {
14266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66494 times.
66494 if(switch_hooked) return enemy::animate(index);
14267
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 65112 times.
66494 if(dying)
14268 1382 return Dead(index);
14269
14270
2/2
✓ Branch 0 taken 62641 times.
✓ Branch 1 taken 2471 times.
65112 if(clk==0)
14271 {
14272 2471 removearmos(x,y,ffcactivated);
14273 2471 }
14274
14275
14276 // check arm status, move dead ones to end of group
14277
2/2
✓ Branch 0 taken 193618 times.
✓ Branch 1 taken 65112 times.
258730 for(int32_t i=0; i<armcnt; i++)
14278 {
14279 193618 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
14280
3/4
✓ Branch 0 taken 193618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 424 times.
✓ Branch 3 taken 193194 times.
193618 if(!cur_arm || cur_arm->dying)
14281 {
14282
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 424 times.
976 for(int32_t j=i; j<armcnt-1; j++)
14283 {
14284 552 zc_swap(arm[j],arm[j+1]);
14285 552 guys.swap(index+j+1,index+j+2);
14286 552 }
14287
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 87 times.
424 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
14288 {
14289 87 leave_item();
14290 87 }
14291 424 --armcnt;
14292 424 --i;
14293 424 continue;
14294 }
14295
2/2
✓ Branch 0 taken 192502 times.
✓ Branch 1 taken 692 times.
193194 if(!adjusted)
14296 {
14297
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 184 times.
692 if(!dmisc2)
14298 {
14299 508 cur_arm->o_tile=o_tile+40;
14300 508 cur_arm->setParent(this);
14301 508 }
14302 else
14303 {
14304 184 cur_arm->o_tile=o_tile+160;
14305 184 cur_arm->setParent(this);
14306 }
14307 692 }
14308 193194 }
14309
14310 65112 adjusted=true;
14311
14312 // move or die
14313
2/2
✓ Branch 0 taken 65029 times.
✓ Branch 1 taken 83 times.
65112 if(armcnt==0)
14314 83 hp=0;
14315 else
14316 {
14317 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
14318
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 step = ((dmisc2 ? 8_zf : 4_zf) - armcnt) * 0.5 + (dstep / 100);
14319
1/2
✓ Branch 0 taken 65029 times.
✗ Branch 1 not taken.
65029 if (step > 4.5_zf) step = 4.5_zf;
14320 65029 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
14321
14322
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 if(!dmisc2)
14323 {
14324
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 53584 times.
204603 for(int32_t i=0; i<armcnt; i++)
14325 {
14326
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14327 {
14328 case 0:
14329 38579 dy1=-24;
14330 38579 break;
14331
14332 case 1:
14333 36328 dy2=31;
14334 36328 break;
14335
14336 case 2:
14337 36250 dx1=-16;
14338 36250 break;
14339
14340 case 3:
14341 39862 dx2=31;
14342 39862 break;
14343 }
14344 151019 }
14345 53584 }
14346 else
14347 {
14348 11445 dx1=-8, dy1=-16, dx2=23, dy2=23;
14349
14350
2/2
✓ Branch 0 taken 42175 times.
✓ Branch 1 taken 11445 times.
53620 for(int32_t i=0; i<armcnt; i++)
14351 {
14352
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12012 times.
✓ Branch 2 taken 7730 times.
✓ Branch 3 taken 9837 times.
✓ Branch 4 taken 12596 times.
42175 switch(arm[i]&3)
14353 {
14354 case 0:
14355 12012 dy1=-32;
14356 12012 break;
14357
14358 case 1:
14359 7730 dy2=39;
14360 7730 break;
14361
14362 case 2:
14363 9837 dx1=-24;
14364 9837 break;
14365
14366 case 3:
14367 12596 dx2=39;
14368 12596 break;
14369 }
14370 42175 }
14371 }
14372
14373 65029 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
14374
14375
2/2
✓ Branch 0 taken 193194 times.
✓ Branch 1 taken 65029 times.
258223 for(int32_t i=0; i<armcnt; i++)
14376 {
14377 193194 zfix dx=(zfix)0,dy=(zfix)0;
14378
14379
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 42175 times.
193194 if(!dmisc2)
14380 {
14381
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14382 {
14383 case 0:
14384 38579 dy=-16;
14385 38579 break;
14386
14387 case 1:
14388 36328 dy=16;
14389 36328 break;
14390
14391 case 2:
14392 36250 dx=-16;
14393 36250 break;
14394
14395 case 3:
14396 39862 dx=16;
14397 39862 break;
14398 }
14399 151019 }
14400 else
14401 {
14402
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5447 times.
✓ Branch 2 taken 3986 times.
✓ Branch 3 taken 4163 times.
✓ Branch 4 taken 6774 times.
✓ Branch 5 taken 6565 times.
✓ Branch 6 taken 3744 times.
✓ Branch 7 taken 5674 times.
✓ Branch 8 taken 5822 times.
42175 switch(arm[i])
14403 {
14404 case 0:
14405 5447 dy=-24;
14406 5447 dx=-8;
14407 5447 break;
14408
14409 case 1:
14410 3986 dy=24;
14411 3986 dx=8;
14412 3986 break;
14413
14414 case 2:
14415 4163 dx=-24;
14416 4163 dy=8;
14417 4163 break;
14418
14419 case 3:
14420 6774 dx=24;
14421 6774 dy=-8;
14422 6774 break;
14423
14424 case 4:
14425 6565 dy=-24;
14426 6565 dx=8;
14427 6565 break;
14428
14429 case 5:
14430 3744 dy=24;
14431 3744 dx=-8;
14432 3744 break;
14433
14434 case 6:
14435 5674 dx=-24;
14436 5674 dy=-8;
14437 5674 break;
14438
14439 case 7:
14440 5822 dx=24;
14441 5822 dy=8;
14442 5822 break;
14443 }
14444 }
14445
14446 193194 guys.spr(index+i+1)->x = x+dx;
14447 193194 guys.spr(index+i+1)->y = y+dy;
14448 193194 }
14449 }
14450
14451 65112 return enemy::animate(index);
14452 66494 }
14453
14454
14455 1751 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
14456 {
14457 1751 int32_t wpnId = w->id;
14458
14459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1751 times.
1751 if(dying)
14460 return 0;
14461
14462
3/4
✓ Branch 0 taken 923 times.
✓ Branch 1 taken 786 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
1751 switch(wpnId)
14463 {
14464 case wBomb:
14465 case wSBomb:
14466 case wSword:
14467 case wHammer:
14468 case wWand:
14469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
786 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(x));
14470
14471 case wLitBomb:
14472 case wLitSBomb:
14473 case wBait:
14474 case wWhistle:
14475 case wFire:
14476 case wWind:
14477 case wSSparkle:
14478 case wFSparkle:
14479 case wPhantom:
14480 1709 return 0;
14481
14482 case wHookshot:
14483 case wBrang:
14484 sfx(WAV_CHINK,pan(x));
14485 break;
14486
14487 default:
14488
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(x));
14489 else sfx(WAV_CHINK,pan(x));
14490
14491 42 }
14492
14493 42 return 1;
14494 1751 }
14495
14496 66490 void eManhandla::draw(BITMAP *dest)
14497 {
14498 66490 tile=o_tile;
14499 66490 int32_t fdiv = frate/4;
14500
1/2
✓ Branch 0 taken 66490 times.
✗ Branch 1 not taken.
66490 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14501
14502
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14503 66490 efrate:((clk>=(frate>>1))?1:0);
14504
14505
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 if(get_qr(qr_NEWENEMYTILES))
14506 {
14507
2/2
✓ Branch 0 taken 11308 times.
✓ Branch 1 taken 37494 times.
48802 if(!dmisc2)
14508 {
14509
8/9
✓ Branch 0 taken 4771 times.
✓ Branch 1 taken 4640 times.
✓ Branch 2 taken 4995 times.
✓ Branch 3 taken 5574 times.
✓ Branch 4 taken 3793 times.
✓ Branch 5 taken 3930 times.
✓ Branch 6 taken 3908 times.
✓ Branch 7 taken 5883 times.
✗ Branch 8 not taken.
37494 switch(dir-8) //directions get screwed up after 8. *shrug*
14510 {
14511 case up: //u
14512 4771 flip=0;
14513 4771 break;
14514
14515 case l_up: //d
14516 4640 flip=0;
14517 4640 tile+=4;
14518 4640 break;
14519
14520 case l_down: //l
14521 4995 flip=0;
14522 4995 tile+=8;
14523 4995 break;
14524
14525 case left: //r
14526 5574 flip=0;
14527 5574 tile+=12;
14528 5574 break;
14529
14530 case r_down: //ul
14531 3793 flip=0;
14532 3793 tile+=20;
14533 3793 break;
14534
14535 case down: //ur
14536 3930 flip=0;
14537 3930 tile+=24;
14538 3930 break;
14539
14540 case r_up: //dl
14541 3908 flip=0;
14542 3908 tile+=28;
14543 3908 break;
14544
14545 case right: //dr
14546 5883 flip=0;
14547 5883 tile+=32;
14548 5883 break;
14549 }
14550
14551 37494 tile+=f2;
14552 37494 enemy::draw(dest);
14553 37494 } //manhandla 2, big body
14554 else
14555 {
14556
14557
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1277 times.
✓ Branch 2 taken 1360 times.
✓ Branch 3 taken 2242 times.
✓ Branch 4 taken 1789 times.
✓ Branch 5 taken 1345 times.
✓ Branch 6 taken 805 times.
✓ Branch 7 taken 948 times.
✓ Branch 8 taken 1542 times.
11308 switch(dir-8) //directions get screwed up after 8. *shrug*
14558 {
14559 case up: //u
14560 1277 flip=0;
14561 1277 break;
14562
14563 case l_up: //d
14564 1360 flip=0;
14565 1360 tile+=8;
14566 1360 break;
14567
14568 case l_down: //l
14569 2242 flip=0;
14570 2242 tile+=40;
14571 2242 break;
14572
14573 case left: //r
14574 1789 flip=0;
14575 1789 tile+=48;
14576 1789 break;
14577
14578 case r_down: //ul
14579 1345 flip=0;
14580 1345 tile+=80;
14581 1345 break;
14582
14583 case down: //ur
14584 805 flip=0;
14585 805 tile+=88;
14586 805 break;
14587
14588 case r_up: //dl
14589 948 flip=0;
14590 948 tile+=120;
14591 948 break;
14592
14593 case right: //dr
14594 1542 flip=0;
14595 1542 tile+=128;
14596 1542 break;
14597 }
14598
14599 11308 tile+=(f2*2);
14600 11308 xofs-=8;
14601 11308 yofs-=8;
14602 11308 drawblock(dest,15);
14603 11308 xofs+=8;
14604 11308 yofs+=8;
14605 }
14606 48802 }
14607 else
14608 {
14609
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 17173 times.
17688 if(!dmisc2)
14610 {
14611 17173 enemy::draw(dest);
14612 17173 }
14613 else
14614 {
14615 515 xofs-=8;
14616 515 yofs-=8;
14617 515 enemy::draw(dest);
14618 515 xofs+=16;
14619 515 enemy::draw(dest);
14620 515 yofs+=16;
14621 515 enemy::draw(dest);
14622 515 xofs-=16;
14623 515 enemy::draw(dest);
14624 515 xofs+=8;
14625 515 yofs-=8;
14626 }
14627 }
14628 66490 }
14629
14630 692 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14631 692 {
14632 692 id=misc=clk;
14633 692 dir = clk & 3;
14634 692 clk=0;
14635 692 mainguy=count_enemy=false;
14636 692 dummy_bool[0]=false;
14637 692 item_set=0;
14638 692 bgsfx=-1;
14639 692 deadsfx = WAV_EDEAD;
14640
2/4
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 692 times.
✗ Branch 3 not taken.
692 flags &= (~guy_never_return);
14641 692 isCore = false;
14642
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if (SIZEflags != 0) init_size_flags();;
14643 692 }
14644
14645 200202 bool esManhandla::animate(int32_t index)
14646 {
14647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200202 times.
200202 if(switch_hooked) return enemy::animate(index);
14648
2/2
✓ Branch 0 taken 7008 times.
✓ Branch 1 taken 193194 times.
200202 if(dying)
14649 7008 return Dead(index);
14650
14651
2/2
✓ Branch 0 taken 12404 times.
✓ Branch 1 taken 180790 times.
193194 if(clk==0)
14652 {
14653 12404 removearmos(x,y,ffcactivated);
14654 12404 }
14655
14656
2/2
✓ Branch 0 taken 165298 times.
✓ Branch 1 taken 27896 times.
193194 if(--clk2<=0)
14657 {
14658 27896 clk2=unsigned(zc_oldrand())%5+5;
14659 27896 clk3^=1;
14660 27896 }
14661
14662
2/2
✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 191703 times.
193194 if(!(zc_oldrand()&127))
14663 {
14664 1491 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
14665 1491 sfx(wpnsfx(wpn),pan(x));
14666 1491 }
14667
14668 193194 return enemy::animate(index);
14669 200202 }
14670
14671 200186 void esManhandla::draw(BITMAP *dest)
14672 {
14673 200186 tile=o_tile;
14674 200186 int32_t fdiv = frate/4;
14675
1/2
✓ Branch 0 taken 200186 times.
✗ Branch 1 not taken.
200186 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14676
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14677 200186 efrate:((clk>=(frate>>1))?1:0);
14678
14679
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 if(get_qr(qr_NEWENEMYTILES))
14680 {
14681
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 39945 times.
✓ Branch 2 taken 36845 times.
✓ Branch 3 taken 39966 times.
✓ Branch 4 taken 41960 times.
158716 switch(misc&3)
14682 {
14683 case up:
14684 39945 break;
14685
14686 case down:
14687 36845 tile+=4;
14688 36845 break;
14689
14690 case left:
14691 39966 tile+=8;
14692 39966 break;
14693
14694 case right:
14695 41960 tile+=12;
14696 41960 break;
14697 }
14698
14699 158716 tile+=f2;
14700 158716 }
14701 else
14702 {
14703
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12394 times.
✓ Branch 2 taken 7883 times.
✓ Branch 3 taken 8961 times.
✓ Branch 4 taken 12232 times.
41470 switch(misc&3)
14704 {
14705 case down:
14706 8961 flip=2;
14707
14708 [[fallthrough]];
14709 case up:
14710 21355 tile=(clk3)?188:189;
14711 21355 break;
14712
14713 case right:
14714 12232 flip=1;
14715 [[fallthrough]];
14716
14717 case left:
14718 20115 tile=(clk3)?186:187;
14719 20115 break;
14720 }
14721 }
14722
14723 200186 enemy::draw(dest);
14724 200186 }
14725
14726 168 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
14727 168 {
14728
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if ( !(editorflags & ENEMY_FLAG5) )
14729 {
14730
2/4
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
168 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, 120, 48);
14731 168 }
14732 else
14733 {
14734 if ( !(editorflags & ENEMY_FLAG6) )
14735 {
14736 x = X; y = Y;
14737 }
14738 else
14739 {
14740 x = X+8; y = Y;
14741 }
14742 }
14743 168 hzsz = 32; // can't be jumped.
14744 168 flameclk=0;
14745 168 misc=clk; // total head count
14746 168 clk3=clk; // live head count
14747 168 clk=0;
14748 168 clk2=60; // fire ball clock
14749 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
14750
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 hp=(guysbuf[id&0xFFF].attributes[1])*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
14751 168 dir = down;
14752 168 hxofs=4;
14753 168 hit_width=8;
14754 // frate=17*4;
14755 168 fading=fade_blue_poof;
14756 //nets+5420;
14757
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 35 times.
168 if(get_qr(qr_NEWENEMYTILES))
14758 {
14759 /*
14760 necktile=o_tile+8;
14761 if (dmisc3)
14762 {
14763 necktile+=8;
14764 }
14765 */
14766 133 necktile=o_tile+dmisc6;
14767 133 }
14768 else
14769 {
14770 35 necktile=s_tile;
14771 }
14772 168 }
14773
14774 155290 bool eGleeok::animate(int32_t index)
14775 {
14776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155290 times.
155290 if(switch_hooked) return enemy::animate(index);
14777
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 153091 times.
155290 if(dying)
14778 2199 return Dead(index);
14779
14780
2/2
✓ Branch 0 taken 152407 times.
✓ Branch 1 taken 684 times.
153091 if(clk==0)
14781 {
14782 684 removearmos(x,y,ffcactivated);
14783 684 }
14784
14785 // Check if a head was killed somehow...
14786
2/2
✓ Branch 0 taken 101719 times.
✓ Branch 1 taken 51372 times.
153091 if(index+1+clk3>=guys.Count())
14787 51372 clk3=guys.Count()-index-1;
14788
2/2
✓ Branch 0 taken 66050 times.
✓ Branch 1 taken 87041 times.
153091 if(index+1+misc>=guys.Count())
14789 87041 misc=guys.Count()-index-1;
14790
14791 //fix for the "kill all enemies" item
14792
2/2
✓ Branch 0 taken 153085 times.
✓ Branch 1 taken 6 times.
153091 if(hp==-1000)
14793 {
14794
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
14795 {
14796 // I haven't seen this fail, but it seems like it ought to be
14797 // possible, so I'm checking for it. - Saf
14798
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14799 break;
14800 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
14801 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
14802 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
14803 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
14804 12 }
14805
14806 6 clk3=0;
14807
14808
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
14809 {
14810
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14811 break;
14812 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14813 12 }
14814 6 }
14815
14816
2/2
✓ Branch 0 taken 403171 times.
✓ Branch 1 taken 153091 times.
556262 for(int32_t i=0; i<clk3; i++)
14817 {
14818 403171 enemy *head = ((enemy*)guys.spr(index+i+1));
14819 403171 head->dummy_int[1]=necktile;
14820 403171 head->setParent(this);
14821
14822
2/2
✓ Branch 0 taken 320127 times.
✓ Branch 1 taken 83044 times.
403171 if(get_qr(qr_NEWENEMYTILES))
14823 {
14824 320127 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
14825 320127 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
14826 320127 }
14827 else
14828 {
14829 83044 head->dummy_int[2]=necktile+1; //connected head tile
14830 83044 head->dummy_int[3]=necktile+2; //flying head tile
14831 }
14832
14833 403171 head->dmisc5=dmisc5; //neck segments
14834
14835 /*
14836 if (dmisc3)
14837 {
14838 head->dummy_bool[0]=true;
14839 }
14840 */
14841
2/2
✓ Branch 0 taken 397516 times.
✓ Branch 1 taken 5655 times.
403171 if(head->hclk)
14842 {
14843
2/2
✓ Branch 0 taken 4427 times.
✓ Branch 1 taken 1228 times.
5655 if(hclk==0)
14844 {
14845 1228 hp -= 1000 - head->hp;
14846 1228 hclk = 33;
14847
14848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1228 times.
1228 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
14849
14850 1228 sfx(WAV_EHIT,pan(int32_t(head->x)));
14851 1228 }
14852
14853 5655 head->hclk = 0;
14854 5655 }
14855
14856 // Must be set in case of naughty ZScripts
14857 403171 head->hp = 1000;
14858 403171 }
14859
14860
2/2
✓ Branch 0 taken 152676 times.
✓ Branch 1 taken 415 times.
153091 if(hp<=(guysbuf[id&0xFFF].attributes[1]) * (clk3 - 1) * game->get_hero_dmgmult())
14861 {
14862 415 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
14863 415 hp=(guysbuf[id&0xFFF].attributes[1])*(--clk3)*game->get_hero_dmgmult();
14864 415 }
14865
14866
2/2
✓ Branch 0 taken 57409 times.
✓ Branch 1 taken 95682 times.
153091 if(!dmisc3)
14867 {
14868
4/4
✓ Branch 0 taken 5291 times.
✓ Branch 1 taken 90391 times.
✓ Branch 2 taken 1287 times.
✓ Branch 3 taken 4004 times.
95682 if(++clk2>72 && !(zc_oldrand()&3))
14869 {
14870 1287 int32_t i = zc::math::SafeMod(zc_oldrand(), misc);
14871 1287 enemy *head = ((enemy*)guys.spr(index+i+1));
14872 1287 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
14873 1287 sfx(wpnsfx(wpn),pan(x));
14874 1287 clk2=0;
14875 1287 }
14876 95682 }
14877 else
14878 {
14879
4/4
✓ Branch 0 taken 2357 times.
✓ Branch 1 taken 55052 times.
✓ Branch 2 taken 1800 times.
✓ Branch 3 taken 557 times.
57409 if(++clk2>100 && !(zc_oldrand()&3))
14880 {
14881 557 enemy *head = ((enemy*)guys.spr(zc::math::SafeMod(zc_oldrand(), misc) + index + 1));
14882 557 head->timer=zc_oldrand()%50+50;
14883 557 clk2=0;
14884 557 }
14885 }
14886
14887
3/4
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 152964 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
153091 if((hp<=0 && !immortal))
14888 {
14889
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 127 times.
517 for(int32_t i=0; i<misc; i++)
14890 390 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14891
14892
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 124 times.
127 if(flags&guy_never_return) never_return(screen_spawned, index);
14893 127 }
14894
14895 153091 return enemy::animate(index);
14896 155290 }
14897
14898 1239 int32_t eGleeok::takehit(weapon*,weapon*)
14899 {
14900 1239 return 0;
14901 }
14902
14903 156918 void eGleeok::draw(BITMAP *dest)
14904 {
14905 156918 tile=o_tile;
14906
14907
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 154719 times.
156918 if(dying)
14908 {
14909 2199 enemy::draw(dest);
14910 2199 return;
14911 }
14912
14913 154719 int32_t f=clk/17;
14914
14915
2/2
✓ Branch 0 taken 120524 times.
✓ Branch 1 taken 34195 times.
154719 if(get_qr(qr_NEWENEMYTILES))
14916 {
14917 // body
14918 120524 xofs=-8;
14919 120524 yofs=32;
14920
14921
4/4
✓ Branch 0 taken 92588 times.
✓ Branch 1 taken 9155 times.
✓ Branch 2 taken 10095 times.
✓ Branch 3 taken 8686 times.
120524 switch(f)
14922
14923 {
14924 case 0:
14925 9155 tile+=0;
14926 9155 break;
14927
14928 case 1:
14929 10095 tile+=2;
14930 10095 break;
14931
14932 case 2:
14933 8686 tile+=4;
14934 8686 break;
14935
14936 default:
14937 92588 tile+=6;
14938 92588 break;
14939 }
14940 120524 }
14941 else
14942 {
14943 // body
14944 34195 xofs=-8;
14945 34195 yofs=32;
14946
14947
3/3
✓ Branch 0 taken 29222 times.
✓ Branch 1 taken 2514 times.
✓ Branch 2 taken 2459 times.
34195 switch(f)
14948 {
14949 case 0:
14950 2514 tile+=0;
14951 2514 break;
14952
14953 case 2:
14954 2459 tile+=4;
14955 2459 break;
14956
14957 default:
14958 29222 tile+=2;
14959 29222 break;
14960 }
14961 }
14962
14963 154719 enemy::drawblock(dest,15);
14964 156918 }
14965
14966 156918 void eGleeok::draw2(BITMAP *dest)
14967 {
14968 // the neck stub
14969 156918 tile=necktile;
14970 156918 xofs=0;
14971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156918 times.
156918 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14972
14973
2/2
✓ Branch 0 taken 34737 times.
✓ Branch 1 taken 122181 times.
156918 if(get_qr(qr_NEWENEMYTILES))
14974 {
14975 122181 tile+=((clk&24)>>3);
14976 122181 }
14977
14978
3/4
✓ Branch 0 taken 154719 times.
✓ Branch 1 taken 2199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154719 times.
156918 if(hp > 0 && !dont_draw())
14979 {
14980 154719 mapscr* scr = get_scr(screen_spawned);
14981
4/4
✓ Branch 0 taken 4731 times.
✓ Branch 1 taken 149988 times.
✓ Branch 2 taken 737 times.
✓ Branch 3 taken 3994 times.
154719 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
14982 737 sprite::drawcloaked(dest);
14983 else
14984 153982 sprite::draw(dest);
14985 154719 }
14986 156918 }
14987
14988
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
1066 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
14989 533 {
14990
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 setParent(prnt);
14991
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 xoffset=0;
14992
2/4
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yoffset=(zfix)((dmisc5*4+2));
14993 // dummy_bool[0]=false;
14994 533 timer=0;
14995 /* fixing */
14996 533 hp=1000;
14997
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 step=1;
14998 533 item_set=0;
14999
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 x = xoffset+parent->x;
15000
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 y = yoffset+parent->y;
15001 533 hxofs=4;
15002 533 hit_width=8;
15003
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 533 times.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15004 533 clk2=clk; // how int32_t to wait before moving first time
15005 533 clk=0;
15006 533 mainguy=count_enemy=false;
15007
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dir=zc_oldrand();
15008 533 clk3=((dir&2)>>1)+2; // left or right
15009 533 dir&=1; // up or down
15010
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dmisc5=vbound(dmisc5,1,255);
15011 533 isCore = false;
15012
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 parentCore = parent->getUID();
15013
2/2
✓ Branch 0 taken 2132 times.
✓ Branch 1 taken 533 times.
2665 for(int32_t i=0; i<dmisc5; i++)
15014 {
15015 2132 nxoffset[i] = 0;
15016 2132 nyoffset[i] = 0;
15017
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
15018
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
15019 2132 }
15020
15021 533 necktile=0;
15022 //TODO compatibility? -DD
15023 /*
15024 for(int32_t i=0; i<4; i++)
15025 {
15026 nx[i]=124;
15027 ny[i]=i*6+48;
15028 }*/
15029 533 bgsfx=-1;
15030 //no need for deadsfx
15031 533 }
15032
15033 515535 bool esGleeok::animate(int32_t index)
15034 {
15035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 515535 times.
515535 if(switch_hooked) return enemy::animate(index);
15036 // don't call removearmos() - it's a segment.
15037
15038 515535 dmisc5=vbound(dmisc5,1,255);
15039
15040
2/2
✓ Branch 0 taken 112773 times.
✓ Branch 1 taken 402762 times.
515535 if(misc == 0)
15041 {
15042 402762 x = (xoffset+parent->x);
15043 402762 y = (yoffset+parent->y);
15044
15045
2/2
✓ Branch 0 taken 1611048 times.
✓ Branch 1 taken 402762 times.
2013810 for(int32_t i=0; i<dmisc5; i++)
15046 {
15047 1611048 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
15048 1611048 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
15049 1611048 }
15050 402762 }
15051
15052 // set up the head tiles
15053 // headtile=nets+5588; //5580, actually. must adjust for direction later on
15054 /*
15055 if (dummy_bool[0]) //if this is a flame gleeok
15056 {
15057 headtile+=180;
15058 }
15059 */
15060 515535 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
15061 515535 flyingheadtile=dummy_int[3];
15062
15063 // set up the neck tiles
15064 515535 necktile=dummy_int[1];
15065
15066
2/2
✓ Branch 0 taken 112702 times.
✓ Branch 1 taken 402833 times.
515535 if(get_qr(qr_NEWENEMYTILES))
15067 {
15068 402833 necktile+=((clk&24)>>3);
15069 402833 }
15070
15071 /*
15072 else
15073 {
15074 necktile=145;
15075 }
15076 */
15077 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
15078
15079
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 402762 times.
✓ Branch 2 taken 112071 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 402 times.
515535 switch(misc)
15080 {
15081 case 0: // live head
15082 // set up the attached head tiles
15083 402762 tile=headtile;
15084
15085
2/2
✓ Branch 0 taken 82942 times.
✓ Branch 1 taken 319820 times.
402762 if(get_qr(qr_NEWENEMYTILES))
15086 {
15087 319820 tile+=((clk&24)>>3);
15088 /*
15089 if (dummy_bool[0]) {
15090 tile+=1561;
15091 }
15092 */
15093 319820 }
15094
15095 /*
15096 else
15097 {
15098 tile=146;
15099 }
15100 */
15101
4/4
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 298314 times.
✓ Branch 2 taken 11616 times.
✓ Branch 3 taken 92832 times.
402762 if(++clk2>=0 && !(clk2&3))
15102 {
15103
2/2
✓ Branch 0 taken 90773 times.
✓ Branch 1 taken 2059 times.
92832 if(y<= (int32_t)parent->y + 8) dir=down;
15104
15105
2/2
✓ Branch 0 taken 90911 times.
✓ Branch 1 taken 1921 times.
92832 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
15106
15107
4/4
✓ Branch 0 taken 9757 times.
✓ Branch 1 taken 83075 times.
✓ Branch 2 taken 9465 times.
✓ Branch 3 taken 292 times.
92832 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
15108 {
15109 292 dir^=1;
15110 292 }
15111
15112 92832 zfix tempx = x;
15113 92832 zfix tempy = y;
15114
15115 92832 sprite::move(step);
15116 92832 xoffset += (x-tempx);
15117 92832 yoffset += (y-tempy);
15118
15119
2/2
✓ Branch 0 taken 3863 times.
✓ Branch 1 taken 88969 times.
92832 if(clk2>=4)
15120 {
15121 3863 clk3^=1;
15122 3863 clk2=-4;
15123 3863 }
15124 else
15125 {
15126
2/2
✓ Branch 0 taken 87991 times.
✓ Branch 1 taken 978 times.
88969 if(x <= (int32_t)parent->x-(dmisc5*6))
15127 {
15128 978 clk3=right;
15129 978 }
15130
15131
2/2
✓ Branch 0 taken 88008 times.
✓ Branch 1 taken 961 times.
88969 if(x >= (int32_t)parent->x+(dmisc5*6))
15132 {
15133 961 clk3=left;
15134 961 }
15135
15136
4/4
✓ Branch 0 taken 60029 times.
✓ Branch 1 taken 28940 times.
✓ Branch 2 taken 56316 times.
✓ Branch 3 taken 3713 times.
88969 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
15137 {
15138 3713 clk3^=1; // x jig
15139 3713 }
15140 else
15141 {
15142
4/4
✓ Branch 0 taken 29223 times.
✓ Branch 1 taken 56033 times.
✓ Branch 2 taken 28372 times.
✓ Branch 3 taken 851 times.
85256 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
15143 {
15144 851 clk3^=1; // x switch back
15145 851 }
15146
15147 85256 clk2=-4;
15148 }
15149 }
15150
15151 92832 zc_swap(dir,clk3);
15152 92832 tempx = x;
15153 92832 tempy = y;
15154 92832 sprite::move(step);
15155 92832 xoffset += (x-tempx);
15156 92832 yoffset += (y-tempy);
15157 92832 zc_swap(dir,clk3);
15158
15159
2/2
✓ Branch 0 taken 278496 times.
✓ Branch 1 taken 92832 times.
371328 for(int32_t i=1; i<dmisc5; i++)
15160 {
15161 278496 nxoffset[i] = (zc_oldrand()%3);
15162 278496 nyoffset[i] = (zc_oldrand()%3);
15163 278496 }
15164 92832 }
15165
15166 402762 break;
15167
15168 case 1: // flying head
15169
2/2
✓ Branch 0 taken 6589 times.
✓ Branch 1 taken 105482 times.
112071 if(clk>=0)
15170
15171 {
15172 105482 variable_walk_8(rate,homing,hrate,spw_floater);
15173 105482 }
15174
15175 112071 break;
15176
15177 // the following are messages sent from the main guy...
15178 case -1: // got chopped off
15179 {
15180 300 misc=1;
15181 300 superman=1;
15182 300 hxofs=xofs=0;
15183 300 hit_width=16;
15184 300 cs=8;
15185 300 clk=-24;
15186 300 clk2=40;
15187 300 dir=(zc_oldrand()&7)+8;
15188 300 step=8.0/9.0;
15189 }
15190 300 break;
15191
15192 case -2: // the big guy is dead
15193 402 return true;
15194 }
15195
15196
2/2
✓ Branch 0 taken 475008 times.
✓ Branch 1 taken 40125 times.
515133 if(timer)
15197 {
15198
2/2
✓ Branch 0 taken 35334 times.
✓ Branch 1 taken 4791 times.
40125 if(!(timer%8))
15199 {
15200 4791 FireBreath(true);
15201 4791 }
15202
15203 40125 --timer;
15204 40125 }
15205
15206 515133 return enemy::animate(index);
15207 515535 }
15208
15209 7080 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
15210 {
15211
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7080 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7080 if ((editorflags & ENEMY_FLAG7) && misc == 1)
15212 {
15213 int32_t wpnId = w->id;
15214
15215 if(dying)
15216 return 0;
15217
15218 switch(wpnId)
15219 {
15220 case wLitBomb:
15221 case wLitSBomb:
15222 case wBait:
15223 case wWhistle:
15224 case wFire:
15225 case wWind:
15226 case wSSparkle:
15227 case wFSparkle:
15228 case wPhantom:
15229 return 0;
15230
15231 case wHookshot:
15232 case wBrang:
15233 case wBeam:
15234 case wArrow:
15235 case wMagic:
15236 case wBomb:
15237 case wSBomb:
15238 sfx(WAV_CHINK,pan(x));
15239 break;
15240 default:
15241 break;
15242 }
15243
15244 return 1;
15245 }
15246 else
15247 {
15248 7080 int32_t ret = enemy::takehit(w,realweap);
15249
15250
2/2
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 5655 times.
7080 if(ret==-1)
15251 5655 return -2; // force it to wait a frame before checking sword attacks again
15252
15253 1425 return ret;
15254 }
15255 7080 }
15256
15257 521456 void esGleeok::draw(BITMAP *dest)
15258 {
15259 521456 dmisc5=vbound(dmisc5,1,255);
15260
15261
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 409106 times.
✓ Branch 2 taken 112350 times.
521456 switch(misc)
15262 {
15263 case 0: //neck
15264
1/2
✓ Branch 0 taken 409106 times.
✗ Branch 1 not taken.
409106 if(!dont_draw())
15265 {
15266
2/2
✓ Branch 0 taken 1227318 times.
✓ Branch 1 taken 409106 times.
1636424 for(int32_t i=1; i<dmisc5; i++) //draw the neck
15267 {
15268 1227318 mapscr* scr = get_scr(screen_spawned);
15269
2/2
✓ Branch 0 taken 978198 times.
✓ Branch 1 taken 249120 times.
1227318 if(get_qr(qr_NEWENEMYTILES))
15270 {
15271
4/4
✓ Branch 0 taken 23100 times.
✓ Branch 1 taken 955098 times.
✓ Branch 2 taken 20889 times.
✓ Branch 3 taken 2211 times.
978198 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15272 2211 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15273 else
15274 975987 overtile16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15275 978198 }
15276 else
15277 {
15278
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 244842 times.
✓ Branch 2 taken 4278 times.
✗ Branch 3 not taken.
249120 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15279 overtilecloaked16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15280 else
15281 249120 overtile16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15282 }
15283 1227318 }
15284 409106 }
15285
15286 409106 break;
15287
15288 case 1: //flying head
15289 112350 tile=flyingheadtile;
15290
15291
2/2
✓ Branch 0 taken 82692 times.
✓ Branch 1 taken 29658 times.
112350 if(get_qr(qr_NEWENEMYTILES))
15292 {
15293 82692 tile+=((clk&24)>>3);
15294 82692 break;
15295 }
15296 29658 }
15297 521456 }
15298
15299 521456 void esGleeok::draw2(BITMAP *dest)
15300 {
15301 521456 enemy::draw(dest);
15302 521456 }
15303
15304 190 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
15305 190 {
15306
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ( !(editorflags & ENEMY_FLAG5) )
15307 {
15308
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 x = 128;
15309
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 y = 48;
15310 190 }
15311 else { x = X; y = Y; }
15312 190 adjusted=false;
15313
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 dir=(zc_oldrand()&7)+8;
15314 //step=0.25;
15315 190 flycnt=dmisc1;
15316 190 flycnt2=dmisc2;
15317 190 loopcnt=0;
15318 190 clk4 = 0;
15319 190 clk5 = 0;
15320 190 clk6 = 0;
15321 190 clk7 = 0;
15322
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
15323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc29 == 0)
15324 {
15325
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15326 {
15327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc29 = (90 / 3);
15328 105 else dmisc29 = (84 / 3);
15329 105 }
15330 else
15331 {
15332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc29 = (90 / 2);
15333 85 else dmisc29 = (84 / 2);
15334 }
15335 190 }
15336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc30 == 0)
15337 {
15338
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15339 {
15340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc30 = (90 / 3)*0.5;
15341 105 else dmisc30 = (84 / 3)*0.5;
15342 105 }
15343 else
15344 {
15345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc30 = (90 / 2)*0.5;
15346 85 else dmisc30 = (84 / 2)*0.5;
15347 }
15348 190 }
15349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc31 == 0)
15350 {
15351
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15352 {
15353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc31 = (90 / 3)*2;
15354 105 else dmisc31 = (84 / 3)*2;
15355 105 }
15356 else
15357 {
15358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc31 = (90 / 2)*0.5;
15359 85 else dmisc31 = (84 / 2)*0.5;
15360 }
15361 190 }
15362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc32 == 0)
15363 {
15364
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15365 {
15366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc32 = (90 / 3);
15367 105 else dmisc32 = (84 / 3);
15368 105 }
15369 else
15370 {
15371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc32 = (90 / 2)*0.25;
15372 85 else dmisc32 = (84 / 2)*0.25;
15373 }
15374 190 }
15375
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 init_size_flags();
15376 190 }
15377
15378 161885 bool ePatra::animate(int32_t index)
15379 {
15380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161885 times.
161885 if(switch_hooked) return enemy::animate(index);
15381
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 160441 times.
161885 if(dying)
15382 {
15383
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1444 times.
1516 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
15384 {
15385 72 auto segment = (enemy*)guys.spr(i);
15386
2/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
72 if (segment && segment->parent == this)
15387 72 segment->hp = -1000;
15388 72 }
15389
15390 1444 return Dead(index);
15391 }
15392
15393 160441 double basesize = 84;
15394
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc10) basesize = 90;
15395 160441 double halfsize = basesize / 2;
15396 160441 double quartersize = halfsize / 2;
15397 160441 double twothirdsize = (basesize / 3)*2;
15398 160441 double onethirdsize = (basesize / 3);
15399
15400
15401
2/2
✓ Branch 0 taken 123507 times.
✓ Branch 1 taken 36934 times.
160441 if(clk==0)
15402 {
15403 36934 removearmos(x,y,ffcactivated);
15404 36934 }
15405
15406
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160441 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
160441 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
15407 {
15408
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
160441 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
15409
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (loopcnt < 0) ++clk2;
15410
2/2
✓ Branch 0 taken 158644 times.
✓ Branch 1 taken 1797 times.
160441 if(++clk2>basesize)
15411 {
15412 1797 clk2=0;
15413
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1797 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1797 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
15414 {
15415
2/2
✓ Branch 0 taken 932 times.
✓ Branch 1 taken 865 times.
1797 if(loopcnt > 0)
15416 932 --loopcnt;
15417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 else if (loopcnt == 0)
15418 {
15419
2/2
✓ Branch 0 taken 509 times.
✓ Branch 1 taken 356 times.
865 if (zc::math::SafeMod(misc, dmisc6) == 0)
15420 {
15421
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 if (dmisc21 > 0) loopcnt=-dmisc21;
15422 356 else loopcnt=dmisc7;
15423 356 }
15424 865 }
15425 else if (loopcnt == -1) loopcnt=dmisc7;
15426 else ++loopcnt;
15427
15428
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1797 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
15429 1797 }
15430 else
15431 {
15432 loopcnt = 0;
15433 misc = 1;
15434 }
15435 1797 }
15436 160441 }
15437
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk4 > 0) --clk4;
15438
15439
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 < 0)
15440 {
15441 if (dmisc5 == 1 || dmisc5 == 3)
15442 {
15443 if (get_qr(qr_NEWENEMYTILES))
15444 {
15445 if (clk7 <= 0 || clk6 != -16) ++clk6;
15446 if (clk6 == 0) o_tile=d->e_tile;
15447 else
15448 {
15449 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
15450 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
15451 }
15452 }
15453 else clk6 = 0;
15454 }
15455 }
15456
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk6;
15457
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk5 < 0) ++clk5;
15458
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk5;
15459
15460
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160441 if (clk7 > 0 && clk6 >= -16) --clk7;
15461
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 > 0) clk7 = 0;
15462
15463
2/2
✓ Branch 0 taken 660384 times.
✓ Branch 1 taken 160441 times.
820825 for(int32_t i=index+1; i<index+flycnt+1; i++)
15464 {
15465 //outside ring
15466
2/2
✓ Branch 0 taken 659040 times.
✓ Branch 1 taken 1344 times.
660384 if(!adjusted)
15467 {
15468
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 192 times.
1344 if(get_qr(qr_NEWENEMYTILES))
15469 {
15470 1152 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
15471 1152 enemy *s = ((enemy*)guys.spr(i));
15472 1152 s->setParent(this);
15473 1152 }
15474 else
15475 {
15476 192 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15477 192 enemy *s = ((enemy*)guys.spr(i));
15478 192 s->setParent(this);
15479 }
15480
15481 1344 ((enemy*)guys.spr(i))->cs=dmisc9;
15482 1344 ((enemy*)guys.spr(i))->hp=dmisc3;
15483 1344 }
15484
15485
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 659620 times.
660384 if(((enemy*)guys.spr(i))->hp <= 0)
15486 {
15487
2/2
✓ Branch 0 taken 2889 times.
✓ Branch 1 taken 764 times.
3653 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15488 {
15489 2889 guys.swap(j,j+1);
15490 2889 }
15491
15492
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 670 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
764 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
15493 764 }
15494 else
15495 {
15496 659620 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15497
1/2
✓ Branch 0 taken 659620 times.
✗ Branch 1 not taken.
659620 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
15498
15499
2/2
✓ Branch 0 taken 212037 times.
✓ Branch 1 taken 447583 times.
659620 if(!dmisc4) //Big Ring
15500 {
15501 //maybe playing_field_offset here?
15502
2/2
✓ Branch 0 taken 237330 times.
✓ Branch 1 taken 210253 times.
447583 if(loopcnt>0)
15503 {
15504
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15505
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15506 237330 }
15507 else
15508 {
15509 210253 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15510 210253 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15511 }
15512
15513 447583 temp_x=guys.spr(i)->x;
15514 447583 temp_y=guys.spr(i)->y;
15515 447583 }
15516 else //Oval
15517 {
15518 212037 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15519 212037 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15520
15521
2/2
✓ Branch 0 taken 121041 times.
✓ Branch 1 taken 90996 times.
212037 if(loopcnt>0)
15522 {
15523 121041 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15524
1/2
✓ Branch 0 taken 121041 times.
✗ Branch 1 not taken.
121041 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
15525 121041 }
15526 else
15527 {
15528 90996 guys.spr(i)->x = circle_x;
15529 90996 guys.spr(i)->y = circle_y;
15530 }
15531
15532 212037 temp_x=circle_x;
15533 212037 temp_y=circle_y;
15534 }
15535
15536 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15537 659620 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15538
15539
4/4
✓ Branch 0 taken 124008 times.
✓ Branch 1 taken 535612 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83117 times.
659620 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15540 {
15541 83117 guys.spr(i)->dir=l_down;
15542 83117 }
15543
4/4
✓ Branch 0 taken 124459 times.
✓ Branch 1 taken 452044 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83568 times.
576503 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15544 {
15545 83568 guys.spr(i)->dir=left;
15546 83568 }
15547
4/4
✓ Branch 0 taken 123345 times.
✓ Branch 1 taken 369590 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82454 times.
492935 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15548 {
15549 82454 guys.spr(i)->dir=l_up;
15550 82454 }
15551
4/4
✓ Branch 0 taken 123079 times.
✓ Branch 1 taken 287402 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82188 times.
410481 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15552 {
15553 82188 guys.spr(i)->dir=up;
15554 82188 }
15555
4/4
✓ Branch 0 taken 122491 times.
✓ Branch 1 taken 205802 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81600 times.
328293 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15556 {
15557 81600 guys.spr(i)->dir=r_up;
15558 81600 }
15559
4/4
✓ Branch 0 taken 122884 times.
✓ Branch 1 taken 123809 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81993 times.
246693 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15560 {
15561 81993 guys.spr(i)->dir=right;
15562 81993 }
15563
4/4
✓ Branch 0 taken 122590 times.
✓ Branch 1 taken 42110 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81699 times.
164700 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15564 {
15565 81699 guys.spr(i)->dir=r_down;
15566 81699 }
15567 else
15568 {
15569 83001 guys.spr(i)->dir=down;
15570 }
15571
15572 659620 guys.spr(i)->x += x;
15573 659620 guys.spr(i)->y += y;
15574 }
15575 660384 }
15576
15577
7/22
✓ Branch 0 taken 106957 times.
✓ Branch 1 taken 53484 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106957 times.
✓ Branch 4 taken 21153 times.
✓ Branch 5 taken 32331 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 21153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 32331 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
160441 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
15578 {
15579 32331 int timeneeded = 48;
15580 32331 int patbreath = (zc_oldrand()%50+50);
15581
2/2
✓ Branch 0 taken 24549 times.
✓ Branch 1 taken 7782 times.
32331 if ((patbreath % 4) == 0) ++patbreath;
15582
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratBREATH)
15583 {
15584 timeneeded = 48 + patbreath;
15585 }
15586
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratSTREAM)
15587 {
15588 timeneeded = 48 + 96;
15589 }
15590
4/14
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32331 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 249 times.
✓ Branch 11 taken 249 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
32331 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
15591
2/2
✓ Branch 0 taken 32331 times.
✓ Branch 1 taken 249 times.
32580 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
15592
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 32082 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
32580 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15593 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)))))
15594 249 && (clk6 >= 0) //if not in the middle of firing...
15595 249 && clk6 >= dmisc19) //if over the set cooldown between shots...
15596
2/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
249 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
15597 {
15598
1/3
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
249 switch(dmisc28)
15599 {
15600 case patratSTREAM:
15601 {
15602 clk7 = 97;
15603 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15604 else clk6 = 0;
15605 break;
15606 }
15607 case patratBREATH:
15608 {
15609 clk7 = patbreath;
15610 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15611 else clk6 = 0;
15612 break;
15613 }
15614 default:
15615 {
15616
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15617 {
15618 clk6 = -48;
15619 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15620 }
15621 else
15622 {
15623 249 clk6 = 0;
15624
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15625 249 FirePatraWeapon();
15626 }
15627 249 break;
15628 }
15629 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15630 249 }
15631
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (clk6 < 0)
15632 {
15633 switch(dmisc28)
15634 {
15635 case patratSTREAM:
15636 {
15637 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
15638 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15639 break;
15640 }
15641 case patratBREATH:
15642 {
15643 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
15644 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15645 break;
15646 }
15647 default:
15648 {
15649 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16)
15650 {
15651 FirePatraWeapon();
15652 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15653 }
15654 break;
15655 }
15656 }
15657 }
15658 32331 }
15659
15660 160441 int randattempts = 0;
15661 160441 int randeye = 0;
15662
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if (flycnt2 > 0)
15663 {
15664 46240 do
15665 {
15666
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✓ Branch 2 taken 44221 times.
✓ Branch 3 taken 2019 times.
46240 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
15667 46240 randeye += (index + flycnt + 1);
15668 46240 ++randattempts;
15669
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46240 times.
46240 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
15670 46240 }
15671 160441 bool dofire = false;
15672
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc20)
15673 {
15674 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15675 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
15676 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
15677 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2))
15678 || (((((zc::math::SafeMod(misc, dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
15679 {
15680 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15681 {
15682 if (clk5 >= dmisc19)
15683 {
15684 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15685 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
15686 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > ((int64_t)48 + 96)) ||
15687 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > 48)))
15688 || dmisc18 == -1)
15689 dofire = true;
15690 }
15691 }
15692 }
15693 }
15694
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if(flycnt2)
15695 {
15696
2/2
✓ Branch 0 taken 334429 times.
✓ Branch 1 taken 46240 times.
380669 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
15697 {
15698
2/2
✓ Branch 0 taken 334117 times.
✓ Branch 1 taken 312 times.
334429 if(!adjusted)
15699 {
15700 312 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
15701
15702
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(get_qr(qr_NEWENEMYTILES))
15703 {
15704
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15705 {
15706
2/3
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 168 times.
✗ Branch 2 not taken.
312 switch(dmisc5)
15707 {
15708 // Center eye shoots projectiles; make room for its firing tiles
15709 case 1:
15710 case 3:
15711 144 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
15712 144 break;
15713
15714 // Center eyes does not shoot; use tiles two rows below for inner eyes.
15715 default:
15716 case 2:
15717 168 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
15718 168 break;
15719 }
15720 312 }
15721 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
15722 312 }
15723 else
15724 {
15725 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15726 }
15727
15728 312 ((enemy*)guys.spr(i))->cs=dmisc9;
15729
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
15730 312 }
15731
15732
2/2
✓ Branch 0 taken 263816 times.
✓ Branch 1 taken 70613 times.
334429 if(flycnt>0)
15733 {
15734 263816 ((enemy*)guys.spr(i))->superman=true;
15735 263816 }
15736 else
15737 {
15738 70613 ((enemy*)guys.spr(i))->superman=false;
15739 }
15740
15741
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 334284 times.
334429 if(((enemy*)guys.spr(i))->hp <= 0)
15742 {
15743
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 145 times.
414 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15744 {
15745 269 guys.swap(j,j+1);
15746 269 }
15747
15748
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
145 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
15749 145 }
15750 else
15751 {
15752 334284 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15753
1/2
✓ Branch 0 taken 334284 times.
✗ Branch 1 not taken.
334284 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
15754
15755
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 327025 times.
334284 if(dmisc4==0)
15756 {
15757
2/2
✓ Branch 0 taken 168378 times.
✓ Branch 1 taken 158647 times.
327025 if(loopcnt>0)
15758 {
15759
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15760
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15761 168378 }
15762 else
15763 {
15764 158647 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15765 158647 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15766 }
15767
15768 327025 temp_x=guys.spr(i)->x;
15769 327025 temp_y=guys.spr(i)->y;
15770 327025 }
15771 else
15772 {
15773 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15774 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15775
15776
2/2
✓ Branch 0 taken 3965 times.
✓ Branch 1 taken 3294 times.
7259 if(loopcnt>0)
15777 {
15778 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15779
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
15780 3965 }
15781 else
15782 {
15783 3294 guys.spr(i)->x = circle_x;
15784 3294 guys.spr(i)->y = circle_y;
15785 }
15786
15787 7259 temp_x=circle_x;
15788 7259 temp_y=circle_y;
15789 }
15790
15791 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15792 334284 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15793
15794
4/4
✓ Branch 0 taken 61619 times.
✓ Branch 1 taken 272665 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41746 times.
334284 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15795 {
15796 41746 guys.spr(i)->dir=l_down;
15797 41746 }
15798
4/4
✓ Branch 0 taken 61607 times.
✓ Branch 1 taken 230931 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41734 times.
292538 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15799 {
15800 41734 guys.spr(i)->dir=left;
15801 41734 }
15802
4/4
✓ Branch 0 taken 61615 times.
✓ Branch 1 taken 189189 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41742 times.
250804 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15803 {
15804 41742 guys.spr(i)->dir=l_up;
15805 41742 }
15806
4/4
✓ Branch 0 taken 61631 times.
✓ Branch 1 taken 147431 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41758 times.
209062 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15807 {
15808 41758 guys.spr(i)->dir=up;
15809 41758 }
15810
4/4
✓ Branch 0 taken 61703 times.
✓ Branch 1 taken 105601 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41830 times.
167304 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15811 {
15812 41830 guys.spr(i)->dir=r_up;
15813 41830 }
15814
4/4
✓ Branch 0 taken 61697 times.
✓ Branch 1 taken 63777 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41824 times.
125474 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15815 {
15816 41824 guys.spr(i)->dir=right;
15817 41824 }
15818
4/4
✓ Branch 0 taken 61725 times.
✓ Branch 1 taken 21925 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41852 times.
83650 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15819 {
15820 41852 guys.spr(i)->dir=r_down;
15821 41852 }
15822 else
15823 {
15824 41798 guys.spr(i)->dir=down;
15825 }
15826
15827 334284 guys.spr(i)->x += x;
15828 334284 guys.spr(i)->y = y-guys.spr(i)->y;
15829
15830
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 334284 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 189016 times.
✓ Branch 5 taken 145268 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 189016 times.
334284 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
15831 {
15832 /*
15833 if(!(zc_oldrand()&127))
15834 {
15835 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
15836 sfx(wpnsfx(wpn),pan(x));
15837 }
15838 */
15839
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
145268 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
15840 {
15841 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
15842 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15843 {
15844 if (dmisc5 == 3)
15845 {
15846 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15847 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
15848 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
15849 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15850 }
15851 else
15852 {
15853 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15854 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15855 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
15856 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15857 }
15858 }
15859 else
15860 {
15861 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15862 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
15863 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
15864 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15865 }
15866 }
15867
4/6
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145268 times.
✓ Branch 4 taken 145268 times.
✓ Branch 5 taken 145268 times.
145268 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
15868
1/2
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
145268 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
15869
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
15870 {
15871
1/5
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
145268 switch(dmisc20) //Patra Attack Patterns
15872 {
15873 case 4: //Single one rapidfires
15874 {
15875 if (dofire && i == randeye)
15876 {
15877 ((esPatra*)guys.spr(i))->clk5 = -16;
15878 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
15879 ((esPatra*)guys.spr(i))->clk4 = 96;
15880 clk5 = -3;
15881 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15882 }
15883 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
15884 {
15885 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15886 sfx(wpnsfx(wpn),pan(x));
15887 }
15888 break;
15889 }
15890 case 3: //Ring
15891 {
15892 if (dofire)
15893 {
15894 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15895 {
15896 ((esPatra*)guys.spr(i))->clk5 = -48;
15897 clk5 = -48;
15898 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15899 }
15900 else
15901 {
15902 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15903 sfx(wpnsfx(wpn),pan(x));
15904 int32_t m=Ewpns.Count()-1;
15905 weapon *ew = (weapon*)(Ewpns.spr(m));
15906
15907 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15908 ((esPatra*)guys.spr(i))->clk5 = 0;
15909 clk5 = 0;
15910 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15911 }
15912 }
15913 if (((esPatra*)guys.spr(i))->clk5 == -16)
15914 {
15915 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15916 sfx(wpnsfx(wpn),pan(x));
15917 int32_t m=Ewpns.Count()-1;
15918 weapon *ew = (weapon*)(Ewpns.spr(m));
15919
15920 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15921 }
15922 break;
15923 }
15924 case 2: //one after another
15925 {
15926 if (dofire)
15927 {
15928 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
15929 clk5 = -48 - (12*flycnt2);
15930 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15931 }
15932 if (((esPatra*)guys.spr(i))->clk5 == -16)
15933 {
15934 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15935 sfx(wpnsfx(wpn),pan(x));
15936 }
15937 break;
15938 }
15939 case 1: //random one eye
15940 {
15941 if (dofire && i == randeye)
15942 {
15943 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15944 {
15945 ((esPatra*)guys.spr(i))->clk5 = -48;
15946 clk5 = -48;
15947 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15948 }
15949 else
15950 {
15951 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15952 sfx(wpnsfx(wpn),pan(x));
15953 ((esPatra*)guys.spr(i))->clk5 = 0;
15954 clk5 = 0;
15955 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15956 }
15957 }
15958 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
15959 {
15960 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15961 sfx(wpnsfx(wpn),pan(x));
15962 }
15963 break;
15964 }
15965 default: //old behavior, all eyes can fire any time
15966 {
15967
3/8
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1155 times.
✓ Branch 5 taken 1155 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15968
3/6
✓ Branch 0 taken 145268 times.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1155 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15969
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15970 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > 48))))
15971 {
15972
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15973 {
15974 ((esPatra*)guys.spr(i))->clk5 = -48;
15975 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15976 }
15977 else
15978 {
15979 1155 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
15980 1155 sfx(wpnsfx(wpn),pan(x));
15981 1155 ((esPatra*)guys.spr(i))->clk5 = 0;
15982
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15983 }
15984 1155 }
15985
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
15986 {
15987 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
15988 sfx(wpnsfx(wpn),pan(x));
15989 }
15990 145268 break;
15991 }
15992 }
15993 145268 }
15994 145268 }
15995
15996 }
15997 334429 }
15998 46240 }
15999
16000 160441 adjusted=true;
16001 160441 return enemy::animate(index);
16002 161885 }
16003
16004 249 void ePatra::FirePatraWeapon()
16005 { //.707
16006 249 int32_t xoff = 0;
16007 249 int32_t yoff = 0;
16008
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_WIDTH)
16009 {
16010 xoff += hxofs;
16011 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
16012 xoff += (hit_width / 2) - (weap_data.tilew * 8);
16013 else
16014 xoff += (hit_width / 2) - 8;
16015 }
16016
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
16017 {
16018 yoff += hyofs;
16019 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
16020 yoff += (hit_height / 2) - (weap_data.tileh * 8);
16021 else
16022 yoff += (hit_height / 2) - 8;
16023 }
16024 249 sfx(wpnsfx(wpn),pan(x));
16025 // TODO(crash): check that .add succeeds.
16026
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
249 switch (dmisc28)
16027 {
16028 case patrat8SHOT: //Fire Wizzrobe
16029 case patrat4SHOTDIAG:
16030 case patrat4SHOTRAND:
16031 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
16032 {
16033 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
16034 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16035 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16036 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16037
16038 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
16039 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16040 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16041 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16042
16043 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
16044 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16045 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16046 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16047
16048 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
16049 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16050 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16051 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16052
16053 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
16054 }
16055
16056 [[fallthrough]];
16057 case patrat4SHOTCARD: //Stalfos 3
16058 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
16059 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16060 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16061 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
16062 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16063 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16064 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
16065 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16066 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16067 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
16068 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16069 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16070 break;
16071
16072 default:
16073 249 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16074
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
16075 249 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
16076
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 249 times.
249 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16077
4/8
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 249 times.
249 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16078 {
16079 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16080 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
16081 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16082 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16083 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16084 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
16085 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16086 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16087 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16088 {
16089 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16090 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
16091 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16092 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16093 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16094 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
16095 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16096 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16097 }
16098 }
16099 249 break;
16100
16101 }
16102 249 sfx(wpnsfx(wpn),pan(x));
16103 //+0.46364761
16104 //11.80
16105 249 }
16106
16107 324242 void ePatra::draw(BITMAP *dest)
16108 {
16109 324242 tile=o_tile;
16110 324242 update_enemy_frame();
16111 324242 enemy::draw(dest);
16112 324242 }
16113
16114 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
16115 {
16116 int32_t ret = enemy::defend(wpnId, power, edef);
16117
16118 if(ret < 0 && (flycnt||flycnt2))
16119 return 0;
16120
16121 return ret;
16122 }
16123
16124 1733 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16125 {
16126 1733 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16127
16128
6/6
✓ Branch 0 taken 1613 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 834 times.
✓ Branch 4 taken 447 times.
✓ Branch 5 taken 332 times.
1733 if(ret < 0 && (flycnt||flycnt2))
16129 1281 return 0;
16130
16131 452 return ret;
16132 1733 }
16133
16134 190 void ePatra::init_size_flags() {
16135 190 SIZEflags = d->SIZEflags;
16136
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16137
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
16138 // al_trace("Enemy txsz:%i\n", txsz);
16139
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = tysz; if (tysz > 1) extend = 3; }
16140
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
16141
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = hit_width;
16142
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hit_width = 32;
16143
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = hit_height;
16144
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = hzsz;
16145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = hxofs;
16146
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hxofs = -8;
16147
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = hyofs;
16148 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)xofs;
16150
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) xofs = -8;
16151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16152 {
16153 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
16154 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16155 }
16156
1/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset) - 8;
16157
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (editorflags & ENEMY_FLAG8) misc = 1;
16158
16159
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)zofs;
16160
16161 190 }
16162
16163 1656 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
16164 1656 {
16165 //cs=8;
16166
1/2
✓ Branch 0 taken 1656 times.
✗ Branch 1 not taken.
1656 setParent(prnt);
16167 1656 item_set=0;
16168 1656 misc=clk;
16169 1656 clk4 = 0;
16170 1656 clk5 = 0;
16171 1656 clk = -((misc*21)>>1)-1;
16172
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16173 1656 hit_width=12;
16174 1656 hit_height=12;
16175 1656 hxofs=2;
16176 1656 hyofs=2;
16177 1656 extend = 0;
16178 1656 txsz = 1;
16179 1656 tysz = 1;
16180 /* //These need to be separate enemy editor fields. This enemy class also its draw altered to correctly support big stuff.
16181 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16182 int32_t prntSIZEflags = prntenemy->SIZEflags;
16183 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16184 // al_trace("Enemy txsz:%i\n", txsz);
16185 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16186 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
16187 else
16188 hxsz=12;
16189 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
16190 else
16191 hysz=12;
16192 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16193 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16194 else
16195 hxofs=2;
16196 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16197 else hyofs=2;
16198 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16199 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16200 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16201 {
16202 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16203 }
16204
16205 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
16206 */
16207 1656 mainguy=count_enemy=false;
16208 1656 bgsfx=-1;
16209 //o_tile=0;
16210
2/4
✓ Branch 0 taken 1656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 flags &= (~guy_never_return);
16211 1656 deadsfx = WAV_EDEAD;
16212 1656 hitsfx = WAV_EHIT;
16213 1656 isCore = false;
16214 1656 }
16215
16216 1010584 bool esPatra::animate(int32_t index)
16217 {
16218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1010584 times.
1010584 if(switch_hooked) return enemy::animate(index);
16219
2/2
✓ Branch 0 taken 15160 times.
✓ Branch 1 taken 995424 times.
1010584 if(dying)
16220 15160 return Dead(index);
16221
16222 995424 return enemy::animate(index);
16223 1010584 }
16224
16225 2028196 void esPatra::draw(BITMAP *dest)
16226 {
16227
2/2
✓ Branch 0 taken 1721294 times.
✓ Branch 1 taken 306902 times.
2028196 if(get_qr(qr_NEWENEMYTILES))
16228 {
16229 1721294 tile = o_tile+(clk&3);
16230
16231
8/9
✓ Branch 0 taken 214278 times.
✓ Branch 1 taken 217924 times.
✓ Branch 2 taken 215346 times.
✓ Branch 3 taken 215726 times.
✓ Branch 4 taken 213062 times.
✓ Branch 5 taken 214350 times.
✓ Branch 6 taken 215734 times.
✓ Branch 7 taken 214874 times.
✗ Branch 8 not taken.
1721294 switch(dir) //directions get screwed up after 8. *shrug*
16232 {
16233 case up: //u
16234 214278 flip=0;
16235 214278 break;
16236
16237 case down: //d
16238 217924 flip=0;
16239 217924 tile+=4;
16240 217924 break;
16241
16242 case left: //l
16243 215346 flip=0;
16244 215346 tile+=8;
16245 215346 break;
16246
16247 case right: //r
16248 215726 flip=0;
16249 215726 tile+=12;
16250 215726 break;
16251
16252 case l_up: //ul
16253 213062 flip=0;
16254 213062 tile+=20;
16255 213062 break;
16256
16257 case r_up: //ur
16258 214350 flip=0;
16259 214350 tile+=24;
16260 214350 break;
16261
16262 case l_down: //dl
16263 215734 flip=0;
16264 215734 tile+=28;
16265 215734 break;
16266
16267 case r_down: //dr
16268 214874 flip=0;
16269 214874 tile+=32;
16270 214874 break;
16271 }
16272 1721294 }
16273 else
16274 {
16275 306902 tile = o_tile+((clk&2)>>1);
16276 }
16277
16278
2/2
✓ Branch 0 taken 114856 times.
✓ Branch 1 taken 1913340 times.
2028196 if(clk>=0)
16279 1913340 enemy::draw(dest);
16280 2028196 }
16281
16282
16283 102 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
16284 102 {
16285 102 adjusted=false;
16286
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 dir=(zc_oldrand()&7)+8;
16287
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 step=0.25;
16288 102 clk4 = 0;
16289 102 clk5 = 0;
16290 //flycnt=6; flycnt2=0;
16291 102 flycnt=dmisc1;
16292 102 flycnt2=0; // PatraBS doesn't have inner rings!
16293 102 loopcnt=0;
16294
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 init_size_flags();
16295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
16296
16297 //nets+4480;
16298 102 }
16299
16300 35963 bool ePatraBS::animate(int32_t index)
16301 {
16302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35963 times.
35963 if(switch_hooked) return enemy::animate(index);
16303
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 35723 times.
35963 if(dying)
16304 240 return Dead(index);
16305
16306
2/2
✓ Branch 0 taken 31705 times.
✓ Branch 1 taken 4018 times.
35723 if(clk==0)
16307 {
16308 4018 removearmos(x,y,ffcactivated);
16309 4018 }
16310
16311 35723 variable_walk_8(rate,homing,hrate,spw_floater);
16312
16313
2/2
✓ Branch 0 taken 35387 times.
✓ Branch 1 taken 336 times.
35723 if(++clk2>90)
16314 {
16315 336 clk2=0;
16316
16317
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 159 times.
336 if(loopcnt)
16318 177 --loopcnt;
16319 else
16320 {
16321
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 75 times.
159 if(zc::math::SafeMod(misc, dmisc6)==0)
16322 84 loopcnt=dmisc7;
16323 }
16324
16325 336 ++misc;
16326 336 }
16327
16328 // double size=1;;
16329
2/2
✓ Branch 0 taken 153472 times.
✓ Branch 1 taken 35723 times.
189195 for(int32_t i=index+1; i<index+flycnt+1; i++)
16330 {
16331
2/2
✓ Branch 0 taken 152860 times.
✓ Branch 1 taken 612 times.
153472 if(!adjusted)
16332 {
16333 612 ((enemy*)guys.spr(i))->hp=dmisc3;
16334
16335
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(get_qr(qr_NEWENEMYTILES))
16336 {
16337 612 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
16338 612 }
16339 else
16340 {
16341 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16342 }
16343
16344 612 ((enemy*)guys.spr(i))->cs = dmisc9;
16345 612 }
16346
16347
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 153368 times.
153472 if(((enemy*)guys.spr(i))->hp <= 0)
16348 {
16349
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 104 times.
235 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16350 {
16351 131 guys.swap(j,j+1);
16352 131 }
16353
16354 104 --flycnt;
16355 104 }
16356 else
16357 {
16358 153368 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16359
1/2
✓ Branch 0 taken 153368 times.
✗ Branch 1 not taken.
153368 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
16360 153368 temp_x = zc::math::Cos(a2+PI/2)*45;
16361 153368 temp_y = -zc::math::Sin(a2+PI/2)*45;
16362
16363
2/2
✓ Branch 0 taken 77643 times.
✓ Branch 1 taken 75725 times.
153368 if(loopcnt>0)
16364 {
16365 77643 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
16366
1/2
✓ Branch 0 taken 77643 times.
✗ Branch 1 not taken.
77643 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
16367 77643 }
16368 else
16369 {
16370 75725 guys.spr(i)->x = temp_x;
16371 75725 guys.spr(i)->y = temp_y;
16372 }
16373
16374 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16375 153368 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16376
16377
4/4
✓ Branch 0 taken 29178 times.
✓ Branch 1 taken 124190 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18812 times.
153368 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16378 {
16379 18812 guys.spr(i)->dir=l_down;
16380 18812 }
16381
4/4
✓ Branch 0 taken 29205 times.
✓ Branch 1 taken 105351 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18839 times.
134556 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16382 {
16383 18839 guys.spr(i)->dir=left;
16384 18839 }
16385
4/4
✓ Branch 0 taken 29168 times.
✓ Branch 1 taken 86549 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18802 times.
115717 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16386 {
16387 18802 guys.spr(i)->dir=l_up;
16388 18802 }
16389
4/4
✓ Branch 0 taken 30509 times.
✓ Branch 1 taken 66406 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 20143 times.
96915 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16390 {
16391 20143 guys.spr(i)->dir=up;
16392 20143 }
16393
4/4
✓ Branch 0 taken 28883 times.
✓ Branch 1 taken 47889 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18517 times.
76772 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16394 {
16395 18517 guys.spr(i)->dir=r_up;
16396 18517 }
16397
4/4
✓ Branch 0 taken 29145 times.
✓ Branch 1 taken 29110 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18779 times.
58255 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16398 {
16399 18779 guys.spr(i)->dir=right;
16400 18779 }
16401
4/4
✓ Branch 0 taken 29358 times.
✓ Branch 1 taken 10118 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18992 times.
39476 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16402 {
16403 18992 guys.spr(i)->dir=r_down;
16404 18992 }
16405 else
16406 {
16407 20484 guys.spr(i)->dir=down;
16408 }
16409
16410 153368 guys.spr(i)->x += x;
16411 153368 guys.spr(i)->y += y;
16412 }
16413 153472 }
16414
16415 35723 adjusted=true;
16416 35723 return enemy::animate(index);
16417 35963 }
16418
16419 72874 void ePatraBS::draw(BITMAP *dest)
16420 {
16421 72874 tile=o_tile;
16422
16423
1/2
✓ Branch 0 taken 72874 times.
✗ Branch 1 not taken.
72874 if(get_qr(qr_NEWENEMYTILES))
16424 {
16425 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16426 72874 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
16427
16428
4/4
✓ Branch 0 taken 27164 times.
✓ Branch 1 taken 45710 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 19146 times.
72874 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16429 {
16430 19146 lookat=l_down;
16431 19146 }
16432
4/4
✓ Branch 0 taken 26316 times.
✓ Branch 1 taken 27412 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 18298 times.
53728 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16433 {
16434 18298 lookat=down;
16435 18298 }
16436
4/4
✓ Branch 0 taken 21642 times.
✓ Branch 1 taken 13788 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 13624 times.
35430 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16437 {
16438 13624 lookat=r_down;
16439 13624 }
16440
4/4
✓ Branch 0 taken 15510 times.
✓ Branch 1 taken 6296 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 7492 times.
21806 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16441 {
16442 7492 lookat=right;
16443 7492 }
16444
4/4
✓ Branch 0 taken 9188 times.
✓ Branch 1 taken 5126 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 1170 times.
14314 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16445 {
16446 1170 lookat=r_up;
16447 1170 }
16448
4/4
✓ Branch 0 taken 8982 times.
✓ Branch 1 taken 4162 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 964 times.
13144 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16449 {
16450 964 lookat=up;
16451 964 }
16452
4/4
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 2462 times.
✓ Branch 2 taken 1700 times.
✓ Branch 3 taken 8018 times.
12180 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16453 {
16454 1700 lookat=l_up;
16455 1700 }
16456 else
16457 {
16458 10480 lookat=left;
16459 }
16460
16461
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 18298 times.
✓ Branch 3 taken 10480 times.
✓ Branch 4 taken 7492 times.
✓ Branch 5 taken 1700 times.
✓ Branch 6 taken 1170 times.
✓ Branch 7 taken 19146 times.
✓ Branch 8 taken 13624 times.
72874 switch(lookat) //directions get screwed up after 8. *shrug*
16462 {
16463 case up: //u
16464 964 flip=0;
16465 964 break;
16466
16467 case down: //d
16468 18298 flip=0;
16469 18298 tile+=8;
16470 18298 break;
16471
16472 case left: //l
16473 10480 flip=0;
16474 10480 tile+=40;
16475 10480 break;
16476
16477 case right: //r
16478 7492 flip=0;
16479 7492 tile+=48;
16480 7492 break;
16481
16482 case l_up: //ul
16483 1700 flip=0;
16484 1700 tile+=80;
16485 1700 break;
16486
16487 case r_up: //ur
16488 1170 flip=0;
16489 1170 tile+=88;
16490 1170 break;
16491
16492 case l_down: //dl
16493 19146 flip=0;
16494 19146 tile+=120;
16495 19146 break;
16496
16497 case r_down: //dr
16498 13624 flip=0;
16499 13624 tile+=128;
16500 13624 break;
16501 }
16502
16503 72874 tile+=(2*(clk&3));
16504 72874 xofs-=8;
16505 72874 yofs-=8;
16506 72874 drawblock(dest,15);
16507 72874 xofs+=8;
16508 72874 yofs+=8;
16509 72874 }
16510 else
16511 {
16512 flip=(clk&1);
16513 xofs-=8;
16514 yofs-=8;
16515 enemy::draw(dest);
16516 xofs+=16;
16517 enemy::draw(dest);
16518 yofs+=16;
16519 enemy::draw(dest);
16520 xofs-=16;
16521 enemy::draw(dest);
16522 xofs+=8;
16523 yofs-=8;
16524 }
16525 72874 }
16526
16527 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
16528 {
16529 int32_t ret = enemy::defend(wpnId, power, edef);
16530
16531 if(ret < 0 && (flycnt||flycnt2))
16532 return 0;
16533
16534 return ret;
16535 }
16536
16537 142 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16538 {
16539 142 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16540
16541
5/6
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60 times.
142 if(ret < 0 && (flycnt||flycnt2))
16542 81 return 0;
16543
16544 61 return ret;
16545 142 }
16546
16547 102 void ePatraBS::init_size_flags()
16548 {
16549 102 SIZEflags = d->SIZEflags;
16550
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16551 // al_trace("Enemy txsz:%i\n", txsz);
16552
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
16553
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
16554 102 else hit_width = 32;
16555
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
16556
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
16557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
16558 102 else hxofs = -8;
16559
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
16560 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16561
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
16562
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16563 {
16564 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16565 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16566 }
16567
16568
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
16569 102 }
16570
16571 612 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
16572 612 {
16573 //cs=csBOSS;
16574
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 setParent(prnt);
16575 612 item_set=0;
16576 612 misc=clk;
16577 612 clk = -((misc*21)>>1)-1;
16578 612 clk4 = 0;
16579 612 clk5 = 0;
16580
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16581 612 int32_t prntSIZEflags = prntenemy->SIZEflags;
16582
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16583 // al_trace("Enemy txsz:%i\n", txsz);
16584
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16585
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width;
16586 612 else hit_width=16;
16587
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height;
16588 612 else hit_height=16;
16589
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16590
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if ( (prntSIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16592 612 else hyofs=2;
16593 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16594
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
16596 {
16597 yofs = (int32_t)prntenemy->yofs;
16598 }
16599
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16600
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
16601
16602 612 bgsfx=-1;
16603 612 mainguy=count_enemy=false;
16604 612 deadsfx = WAV_EDEAD;
16605 612 hitsfx = WAV_EHIT;
16606
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 flags &= ~guy_never_return;
16607 612 isCore = false;
16608 612 }
16609
16610 155090 bool esPatraBS::animate(int32_t index)
16611 {
16612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155090 times.
155090 if(switch_hooked) return enemy::animate(index);
16613
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 153538 times.
155090 if(dying)
16614 1552 return Dead(index);
16615
16616 153538 return enemy::animate(index);
16617 155090 }
16618
16619 315868 void esPatraBS::draw(BITMAP *dest)
16620 {
16621 315868 tile=o_tile;
16622
16623
1/2
✓ Branch 0 taken 315868 times.
✗ Branch 1 not taken.
315868 if(get_qr(qr_NEWENEMYTILES))
16624 {
16625
8/9
✓ Branch 0 taken 41612 times.
✓ Branch 1 taken 42622 times.
✓ Branch 2 taken 37916 times.
✓ Branch 3 taken 38458 times.
✓ Branch 4 taken 38564 times.
✓ Branch 5 taken 38568 times.
✓ Branch 6 taken 38662 times.
✓ Branch 7 taken 39466 times.
✗ Branch 8 not taken.
315868 switch(dir) //directions get screwed up after 8. *shrug*
16626 {
16627 case up: //u
16628 41612 flip=0;
16629 41612 break;
16630
16631 case down: //d
16632 42622 flip=0;
16633 42622 tile+=4;
16634 42622 break;
16635
16636 case left: //l
16637 37916 flip=0;
16638 37916 tile+=8;
16639 37916 break;
16640
16641 case right: //r
16642 38458 flip=0;
16643 38458 tile+=12;
16644 38458 break;
16645
16646 case l_up: //ul
16647 38564 flip=0;
16648 38564 tile+=20;
16649 38564 break;
16650
16651 case r_up: //ur
16652 38568 flip=0;
16653 38568 tile+=24;
16654 38568 break;
16655
16656 case l_down: //dl
16657 38662 flip=0;
16658 38662 tile+=28;
16659 38662 break;
16660
16661 case r_down: //dr
16662 39466 flip=0;
16663 39466 tile+=32;
16664 39466 break;
16665 }
16666
16667 315868 tile += ((clk&6)>>1);
16668 315868 }
16669 else
16670 {
16671 tile += (clk&4)?1:0;
16672 }
16673
16674
2/2
✓ Branch 0 taken 32116 times.
✓ Branch 1 taken 283752 times.
315868 if(clk>=0)
16675 283752 enemy::draw(dest);
16676 315868 }
16677
16678 257618 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
16679 {
16680
4/6
✓ Branch 0 taken 150748 times.
✓ Branch 1 taken 106870 times.
✓ Branch 2 taken 150748 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150748 times.
✗ Branch 5 not taken.
257618 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
16681
4/8
✓ Branch 0 taken 257618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 257618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 257618 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 257618 times.
✗ Branch 7 not taken.
257618 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
16682
1/2
✓ Branch 0 taken 257618 times.
✗ Branch 1 not taken.
257618 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16683 257618 }
16684
16685 74710 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
16686 {
16687 // Kludge
16688
4/8
✓ Branch 0 taken 74710 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74710 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74710 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 74710 times.
✗ Branch 7 not taken.
74710 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
16689 74710 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
16690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74710 times.
74710 delete w;
16691 74710 return ret;
16692 }
16693
16694 9214 void enemy_scored(int32_t index)
16695 {
16696 9214 ((enemy*)guys.spr(index))->scored=true;
16697 9214 }
16698
16699 2191 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr)
16700 {
16701
5/8
✓ Branch 0 taken 2191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2191 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 279 times.
✓ Branch 5 taken 1912 times.
✓ Branch 6 taken 2191 times.
✗ Branch 7 not taken.
2191 guy *g = new guy((zfix)x,(zfix)y,id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy);
16702
2/2
✓ Branch 0 taken 1426 times.
✓ Branch 1 taken 765 times.
2191 if (isdungeon(g->screen_spawned))
16703 765 g->y += 1;
16704
5/6
✓ Branch 0 taken 1277 times.
✓ Branch 1 taken 914 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1273 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
2191 if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING))
16705 {
16706 4 g->o_tile = parentscr->guytile;
16707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(g->o_tile != 0)
16708 4 g->flags &= ~guy_invisible;
16709 4 g->cs = parentscr->guycs;
16710 4 }
16711 2191 guys.add(g);
16712 2191 }
16713
16714 23701 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16715 {
16716
4/8
✓ Branch 0 taken 23701 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23701 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23701 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23701 times.
✗ Branch 7 not taken.
23701 item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), 0_zf, id, pickup, 0);
16717 23701 items.add(i);
16718 23701 }
16719
16720 150 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
16721 {
16722
5/10
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 150 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 150 times.
✗ Branch 9 not taken.
150 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
16723 150 items.add(i);
16724 150 }
16725
16726 3 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16727 {
16728
5/10
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
3 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
16729 3 items.add(i);
16730 3 }
16731
16732 19326 void add_item_for_screen(int32_t screen, item* item)
16733 {
16734 19326 item->screen_spawned = screen;
16735 19326 items.add(item);
16736 19326 }
16737
16738 96 void kill_em_all()
16739 {
16740
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 96 times.
449 for(int32_t i=0; i<guys.Count(); i++)
16741 {
16742 353 enemy *e = ((enemy*)guys.spr(i));
16743
16744
3/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 323 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
353 if(e->flags&(1<<3) && !(e->type == eeGHINI && e->dmisc1 == 1)) continue;
16745
16746 323 e->kickbucket();
16747 323 }
16748 96 }
16749
16750 bool can_kill_em_all()
16751 {
16752 for(int32_t i=0; i<guys.Count(); i++)
16753 {
16754 enemy *e = ((enemy*)guys.spr(i));
16755
16756 if(e->flags&(1<<3) && !(e->type == eeGHINI && e->dmisc1 == 1)) continue;
16757 if(e->superman) continue;
16758 return true;
16759 }
16760 return false;
16761 }
16762
16763 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
16764 // For Hero's hit detection. Don't count them if they are stunned or are guys.
16765 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16766 {
16767 for(int32_t i=0; i<guys.Count(); i++)
16768 {
16769 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16770 {
16771 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
16772 &&(((enemy*)guys.spr(i))->d->type != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
16773 {
16774 return i;
16775 }
16776 }
16777 }
16778
16779 return -1;
16780 }
16781
16782 13157767 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16783 {
16784
4/4
✓ Branch 0 taken 16511 times.
✓ Branch 1 taken 13141256 times.
✓ Branch 2 taken 33818802 times.
✓ Branch 3 taken 13126788 times.
46945590 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
16785 {
16786
2/2
✓ Branch 0 taken 30979 times.
✓ Branch 1 taken 33787823 times.
33818802 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16787 {
16788 30979 return i;
16789 }
16790 33787823 }
16791
16792 13126788 return -1;
16793 13157767 }
16794
16795 // For Hero's hit detection. Count them if they are dying.
16796 52508 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16797 {
16798 52508 enemy *e = (enemy*)guys.spr(index);
16799
3/4
✓ Branch 0 taken 52508 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28055 times.
✓ Branch 3 taken 24453 times.
52508 if(!e || e->hp > 0)
16800 28055 return -1;
16801
16802 24453 bool d = e->dying;
16803 24453 int32_t hc = e->hclk;
16804 24453 e->dying = false;
16805 24453 e->hclk = 0;
16806 24453 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
16807 24453 e->dying = d;
16808 24453 e->hclk = hc;
16809
16810
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 24296 times.
24453 return hit ? index : -1;
16811 52508 }
16812
16813 14675165 bool hasMainGuy(int screen)
16814 {
16815
2/2
✓ Branch 0 taken 15979810 times.
✓ Branch 1 taken 5951056 times.
21930866 for(int32_t i=0; i<guys.Count(); i++)
16816 {
16817 15979810 enemy* e = (enemy*)guys.spr(i);
16818
4/4
✓ Branch 0 taken 15516726 times.
✓ Branch 1 taken 463084 times.
✓ Branch 2 taken 8724109 times.
✓ Branch 3 taken 6792617 times.
15979810 if (e->screen_spawned == screen && e->mainguy)
16819 {
16820 8724109 return true;
16821 }
16822 7255701 }
16823
16824 5951056 return false;
16825 14675165 }
16826
16827 138 void EatHero(int32_t index)
16828 {
16829 138 ((eStalfos*)guys.spr(index))->eathero();
16830 138 }
16831
16832 9 void GrabHero(int32_t index)
16833 {
16834 9 ((eWallM*)guys.spr(index))->grabhero();
16835 9 }
16836
16837 1338 bool CarryHero()
16838 {
16839
1/2
✓ Branch 0 taken 3933 times.
✗ Branch 1 not taken.
3933 for(int32_t i=0; i<guys.Count(); i++)
16840 {
16841
2/2
✓ Branch 0 taken 2090 times.
✓ Branch 1 taken 1843 times.
3933 if(((guy*)(guys.spr(i)))->type==eeWALLM)
16842 {
16843
2/2
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 505 times.
1843 if(((eWallM*)guys.spr(i))->hashero)
16844 {
16845 1338 Hero.x=guys.spr(i)->x;
16846 1338 Hero.y=guys.spr(i)->y;
16847 1338 return ((eWallM*)guys.spr(i))->misc > 0;
16848 }
16849 505 }
16850
16851 // Like Likes currently can't carry Hero.
16852 /*
16853 if(((guy*)(guys.spr(i)))->family==eeLIKE)
16854 {
16855 if(((eLikeLike*)guys.spr(i))->hashero)
16856 {
16857 Hero.x=guys.spr(i)->x;
16858 Hero.y=guys.spr(i)->y;
16859 return (true);
16860 }
16861 }*/
16862 2595 }
16863
16864 return false;
16865 1338 }
16866
16867 // Move item with guy
16868 void movefairy(zfix &x,zfix &y,int32_t misc)
16869 {
16870 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16871
16872 if(i!=-1)
16873 {
16874 x = guys.spr(i)->x;
16875 y = guys.spr(i)->y;
16876 }
16877 }
16878
16879 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16880 void movefairy2(zfix x,zfix y,int32_t misc)
16881 {
16882 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16883
16884 if(i!=-1)
16885 {
16886 guys.spr(i)->x = x;
16887 guys.spr(i)->y = y;
16888 }
16889 }// Move item with guy
16890
16891 60788 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
16892 {
16893 60788 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16894
16895
1/2
✓ Branch 0 taken 60788 times.
✗ Branch 1 not taken.
60788 if(fairy)
16896 {
16897 60788 x = fairy->x;
16898 60788 y = fairy->y;
16899 60788 }
16900 60788 }
16901
16902 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16903 404 void movefairynew2(zfix x,zfix y, item const &itemfairy)
16904 {
16905 404 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16906
16907
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 if(fairy)
16908 {
16909 404 fairy->x = x;
16910 404 fairy->y = y;
16911 404 }
16912 404 }
16913
16914 void killfairy(int32_t misc)
16915 {
16916 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16917 guys.del(i);
16918 }
16919
16920 219 int32_t getGuyIndex(const int32_t eid)
16921 {
16922
1/2
✓ Branch 0 taken 828 times.
✗ Branch 1 not taken.
828 for(word i = 0; i < guys.Count(); i++)
16923 {
16924
2/2
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 609 times.
828 if(guys.spr(i)->getUID() == eid)
16925 219 return i;
16926 609 }
16927
16928 return -1;
16929 219 }
16930
16931 219 void killfairynew(item const &itemfairy)
16932 {
16933 219 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16934
1/2
✓ Branch 0 taken 219 times.
✗ Branch 1 not taken.
219 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
16935 219 }
16936
16937 //Should probably change this to return an 'enemy*', null on failure -Em
16938 21822 int32_t addenemy(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk)
16939 {
16940 21822 return addenemy_z(screen,x,y,0,id,clk);
16941 }
16942
16943 1965 int32_t addchild(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk, sprite* parent)
16944 {
16945 1965 return addchild_z(screen,x,y,0,id,clk, parent);
16946 }
16947
16948 1997 int32_t addchild_z(int32_t screen, int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, sprite* parent)
16949 {
16950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1997 times.
1997 if(id <= 0) return 0;
16951
16952 1997 int32_t ret = 0;
16953 1997 sprite *e=NULL;
16954
16955
6/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1865 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1997 switch(guysbuf[id&0xFFF].type)
16956 {
16957 //Fixme: possible enemy memory leak. (minor)
16958 case eeWALK:
16959
3/6
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
110 e = new eStalfos((zfix)x,(zfix)y,id,clk);
16960 110 break;
16961
16962 case eeLEV:
16963 e = new eLeever((zfix)x,(zfix)y,id,clk);
16964 break;
16965
16966 case eeTEK:
16967 e = new eTektite((zfix)x,(zfix)y,id,clk);
16968 break;
16969
16970 case eePEAHAT:
16971 e = new ePeahat((zfix)x,(zfix)y,id,clk);
16972 break;
16973
16974 case eeZORA:
16975 e = new eZora((zfix)x,(zfix)y,id,clk);
16976 break;
16977
16978 case eeGHINI:
16979 e = new eGhini((zfix)x,(zfix)y,id,clk);
16980 break;
16981
16982 case eeKEESE:
16983
3/6
✓ Branch 0 taken 1865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1865 times.
✗ Branch 5 not taken.
1865 e = new eKeese((zfix)x,(zfix)y,id,clk);
16984 1865 break;
16985
16986 case eeWIZZ:
16987
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
16988 15 break;
16989
16990 case eePROJECTILE:
16991 e = new eProjectile((zfix)x,(zfix)y,id,clk);
16992 break;
16993
16994 case eeWALLM:
16995 e = new eWallM((zfix)x,(zfix)y,id,clk);
16996 break;
16997
16998 case eeAQUA:
16999 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17000 break;
17001
17002 case eeMOLD:
17003 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17004 break;
17005
17006 case eeMANHAN:
17007
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17008 1 break;
17009
17010 case eeGLEEOK:
17011 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17012 break;
17013
17014 case eeGHOMA:
17015 e = new eGohma((zfix)x,(zfix)y,id,clk);
17016 break;
17017
17018 case eeLANM:
17019 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17020 break;
17021
17022 case eeGANON:
17023 e = new eGanon((zfix)x,(zfix)y,id,clk);
17024 break;
17025
17026 case eeFAIRY:
17027 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17028 break;
17029
17030 case eeFIRE:
17031
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eFire((zfix)x,(zfix)y,id,clk);
17032 2 break;
17033
17034 case eeOTHER:
17035 e = new eOther((zfix)x,(zfix)y,id,clk);
17036 break;
17037
17038
17039 case eeSCRIPT01:
17040 case eeSCRIPT02:
17041 case eeSCRIPT03:
17042 case eeSCRIPT04:
17043 case eeSCRIPT05:
17044 case eeSCRIPT06:
17045 case eeSCRIPT07:
17046 case eeSCRIPT08:
17047 case eeSCRIPT09:
17048 case eeSCRIPT10:
17049 case eeSCRIPT11:
17050 case eeSCRIPT12:
17051 case eeSCRIPT13:
17052 case eeSCRIPT14:
17053 case eeSCRIPT15:
17054 case eeSCRIPT16:
17055 case eeSCRIPT17:
17056 case eeSCRIPT18:
17057 case eeSCRIPT19:
17058 case eeSCRIPT20:
17059 {
17060 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17061 {
17062 e = new eScript((zfix)x,(zfix)y,id,clk);
17063 break;
17064 }
17065 else return 0;
17066 }
17067
17068 case eeFFRIENDLY01:
17069 case eeFFRIENDLY02:
17070 case eeFFRIENDLY03:
17071 case eeFFRIENDLY04:
17072 case eeFFRIENDLY05:
17073 case eeFFRIENDLY06:
17074 case eeFFRIENDLY07:
17075 case eeFFRIENDLY08:
17076 case eeFFRIENDLY09:
17077 case eeFFRIENDLY10:
17078 {
17079 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17080 {
17081 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17082 }
17083 else return 0;
17084
17085 }
17086
17087 case eeSPINTILE:
17088 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17089 break;
17090
17091 // and these enemies use the misc10/misc2 value
17092 case eeROCK:
17093 {
17094 switch(guysbuf[id&0xFFF].attributes[9])
17095 {
17096 case 1:
17097 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17098 break;
17099
17100 case 0:
17101 default:
17102 e = new eRock((zfix)x,(zfix)y,id,clk);
17103 break;
17104 }
17105
17106 break;
17107 }
17108
17109 case eeTRAP:
17110 {
17111 switch(guysbuf[id&0xFFF].attributes[1])
17112 {
17113 case 1:
17114 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17115 break;
17116
17117 case 0:
17118 default:
17119 e = new eTrap((zfix)x,(zfix)y,id,clk);
17120 break;
17121 }
17122
17123 break;
17124 }
17125
17126 case eeDONGO:
17127 {
17128 switch(guysbuf[id&0xFFF].attributes[9])
17129 {
17130 case 1:
17131 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17132 break;
17133
17134 case 0:
17135 default:
17136 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17137 break;
17138 }
17139
17140 break;
17141 }
17142
17143 case eeDIG:
17144 {
17145
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].attributes[9])
17146 {
17147 case 1:
17148 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17149 break;
17150
17151 4 case 0:
17152 default:
17153
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17154 4 break;
17155 }
17156
17157 4 break;
17158 }
17159
17160 case eePATRA:
17161 {
17162 switch(guysbuf[id&0xFFF].attributes[9])
17163 {
17164 case 1:
17165 if (get_qr(qr_HARDCODED_BS_PATRA))
17166 {
17167 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17168 break;
17169 }
17170 [[fallthrough]];
17171 case 0:
17172 default:
17173 e = new ePatra((zfix)x,(zfix)y,id,clk);
17174 break;
17175 }
17176
17177 break;
17178 }
17179
17180 case eeGUY:
17181 {
17182 switch(guysbuf[id&0xFFF].attributes[9])
17183 {
17184 case 1:
17185 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17186 break;
17187
17188 case 0:
17189 default:
17190 e = new eNPC((zfix)x,(zfix)y,id,clk);
17191 break;
17192 }
17193
17194 break;
17195 }
17196
17197 case eeNONE:
17198 if(guysbuf[id&0xFFF].attributes[9] ==1)
17199 {
17200 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17201 break;
17202 break;
17203 }
17204 [[fallthrough]];
17205 default:
17206
17207 return 0;
17208 }
17209
17210 1997 ret++; // Made one enemy.
17211
17212
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
1997 if(z && canfall(id))
17213 {
17214 7 e->z = (zfix)z;
17215 7 }
17216
17217
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 7 times.
1997 ((enemy*)e)->ceiling = (z && canfall(id));
17218 1997 e->setParent(parent);
17219
17220
1/2
✓ Branch 0 taken 1997 times.
✗ Branch 1 not taken.
1997 if(!guys.add(e))
17221 {
17222 return 0;
17223 }
17224
17225 // add segments of segmented enemies
17226 1997 int32_t c=0;
17227
17228
2/6
✓ Branch 0 taken 1996 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1997 switch(guysbuf[id&0xFFF].type)
17229 {
17230 case eeMOLD:
17231 {
17232 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17233 id &= 0xFFF;
17234
17235 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17236 {
17237 //christ this is messy -DD
17238 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17239
17240 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17241 {
17242 al_trace("Moldorm segment %d could not be created!\n",i+1);
17243
17244 for(int32_t j=0; j<i+1; j++)
17245 guys.del(guys.Count()-1);
17246
17247 return 0;
17248 }
17249
17250 if(i>0)
17251 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17252
17253 ret++;
17254 }
17255
17256 break;
17257 }
17258
17259 case eeLANM:
17260 {
17261 id &= 0xFFF;
17262 int32_t shft = guysbuf[id].attributes[1];
17263 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17264
17265 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17266 {
17267 al_trace("Lanmola segment 1 could not be created!\n");
17268 guys.del(guys.Count()-1);
17269 return 0;
17270 }
17271
17272 ret++;
17273
17274 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17275 {
17276 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17277 {
17278 al_trace("Lanmola segment %d could not be created!\n",i+1);
17279
17280 for(int32_t j=0; j<i+1; j++)
17281 guys.del(guys.Count()-1);
17282
17283 return 0;
17284 }
17285
17286 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17287 ret++;
17288 }
17289 }
17290 break;
17291
17292 case eeMANHAN:
17293 1 id &= 0xFFF;
17294
17295
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17296 {
17297
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17298 {
17299 al_trace("Manhandla head %d could not be created!\n",i+1);
17300
17301 for(int32_t j=0; j<i+1; j++)
17302 {
17303 guys.del(guys.Count()-1);
17304 }
17305
17306 return 0;
17307 }
17308
17309 4 ret++;
17310 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17311 4 }
17312
17313 1 break;
17314
17315 case eeGLEEOK:
17316 {
17317 id &= 0xFFF;
17318
17319 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17320 {
17321 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
17322 {
17323 al_trace("Gleeok head %d could not be created!\n",i+1);
17324
17325 for(int32_t j=0; j<i+1; j++)
17326 {
17327 guys.del(guys.Count()-1);
17328 }
17329
17330 return false;
17331 }
17332
17333 c-=guysbuf[id].attributes[3];
17334 ret++;
17335 }
17336 }
17337 break;
17338
17339
17340 case eePATRA:
17341 {
17342 id &= 0xFFF;
17343 int32_t outeyes = 0;
17344
17345 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17346 {
17347 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17348 {
17349 al_trace("Patra outer eye %d could not be created!\n",i+1);
17350
17351 for(int32_t j=0; j<i+1; j++)
17352 guys.del(guys.Count()-1);
17353
17354 return 0;
17355 }
17356 else
17357 outeyes++;
17358
17359 ret++;
17360 }
17361
17362 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17363 {
17364 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17365 {
17366 al_trace("Patra inner eye %d could not be created!\n",i+1);
17367
17368 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17369 guys.del(guys.Count()-1);
17370
17371 return 0;
17372 }
17373
17374 ret++;
17375 }
17376
17377 break;
17378 }
17379 }
17380
17381
2/2
✓ Branch 0 taken 2001 times.
✓ Branch 1 taken 1997 times.
3998 for (int i = 0; i < ret; i++)
17382 {
17383 2001 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17384 2001 e->screen_spawned = screen;
17385 2001 }
17386
17387 1997 return ret;
17388 1997 }
17389
17390 // Returns number of enemies/segments created
17391 102142 int32_t addenemy_z(int32_t screen,int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
17392 {
17393 102142 int32_t realid = id&0xFFF;
17394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102142 times.
102142 if( realid > MAXGUYS )
17395 {
17396 return 0;
17397 }
17398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102142 times.
102142 if(id <= 0) return 0;
17399
17400 102142 int32_t ret = 0;
17401 102142 sprite *e=NULL;
17402
17403
28/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50147 times.
✓ Branch 4 taken 3942 times.
✓ Branch 5 taken 5212 times.
✓ Branch 6 taken 1825 times.
✓ Branch 7 taken 2797 times.
✓ Branch 8 taken 461 times.
✓ Branch 9 taken 11855 times.
✓ Branch 10 taken 5335 times.
✓ Branch 11 taken 4429 times.
✓ Branch 12 taken 998 times.
✓ Branch 13 taken 126 times.
✓ Branch 14 taken 618 times.
✓ Branch 15 taken 149 times.
✓ Branch 16 taken 168 times.
✓ Branch 17 taken 93 times.
✓ Branch 18 taken 420 times.
✓ Branch 19 taken 13 times.
✓ Branch 20 taken 732 times.
✓ Branch 21 taken 758 times.
✓ Branch 22 taken 7630 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 384 times.
✓ Branch 25 taken 2472 times.
✓ Branch 26 taken 251 times.
✓ Branch 27 taken 403 times.
✓ Branch 28 taken 292 times.
✓ Branch 29 taken 5 times.
✓ Branch 30 taken 533 times.
102142 switch(guysbuf[id&0xFFF].type)
17404 {
17405 //Fixme: possible enemy memory leak. (minor)
17406 case eeWALK:
17407
3/6
✓ Branch 0 taken 50147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50147 times.
✗ Branch 5 not taken.
50147 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17408 50147 break;
17409
17410 case eeLEV:
17411
3/6
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3942 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3942 times.
✗ Branch 5 not taken.
3942 e = new eLeever((zfix)x,(zfix)y,id,clk);
17412 3942 break;
17413
17414 case eeTEK:
17415
3/6
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5212 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5212 times.
✗ Branch 5 not taken.
5212 e = new eTektite((zfix)x,(zfix)y,id,clk);
17416 5212 break;
17417
17418 case eePEAHAT:
17419
3/6
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
1825 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17420 1825 break;
17421
17422 case eeZORA:
17423
3/6
✓ Branch 0 taken 2797 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2797 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2797 times.
✗ Branch 5 not taken.
2797 e = new eZora((zfix)x,(zfix)y,id,clk);
17424 2797 break;
17425
17426 case eeGHINI:
17427
3/6
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 461 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 461 times.
✗ Branch 5 not taken.
461 e = new eGhini((zfix)x,(zfix)y,id,clk);
17428 461 break;
17429
17430 case eeKEESE:
17431
3/6
✓ Branch 0 taken 11855 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11855 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11855 times.
✗ Branch 5 not taken.
11855 e = new eKeese((zfix)x,(zfix)y,id,clk);
17432 11855 break;
17433
17434 case eeWIZZ:
17435
3/6
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5335 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5335 times.
✗ Branch 5 not taken.
5335 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17436 5335 break;
17437
17438 case eePROJECTILE:
17439
3/6
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4429 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4429 times.
✗ Branch 5 not taken.
4429 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17440 4429 break;
17441
17442 case eeWALLM:
17443
3/6
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 998 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 998 times.
✗ Branch 5 not taken.
998 e = new eWallM((zfix)x,(zfix)y,id,clk);
17444 998 break;
17445
17446 case eeAQUA:
17447
3/6
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126 times.
✗ Branch 5 not taken.
126 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17448 126 break;
17449
17450 case eeMOLD:
17451
6/12
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 618 times.
✓ Branch 6 taken 618 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 618 times.
✓ Branch 10 taken 618 times.
✗ Branch 11 not taken.
618 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17452 618 break;
17453
17454 case eeMANHAN:
17455
3/6
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
149 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17456 149 break;
17457
17458 case eeGLEEOK:
17459
7/12
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
✓ Branch 6 taken 152 times.
✓ Branch 7 taken 16 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 152 times.
✓ Branch 10 taken 168 times.
✗ Branch 11 not taken.
168 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17460 168 break;
17461
17462 case eeGHOMA:
17463
3/6
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93 times.
✗ Branch 5 not taken.
93 e = new eGohma((zfix)x,(zfix)y,id,clk);
17464 93 break;
17465
17466 case eeLANM:
17467
6/12
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 420 times.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 420 times.
✓ Branch 10 taken 420 times.
✗ Branch 11 not taken.
420 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17468 420 break;
17469
17470 case eeGANON:
17471
3/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 e = new eGanon((zfix)x,(zfix)y,id,clk);
17472 13 break;
17473
17474 case eeFAIRY:
17475
3/6
✓ Branch 0 taken 732 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 732 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 732 times.
✗ Branch 5 not taken.
732 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17476 732 break;
17477
17478 case eeFIRE:
17479
3/6
✓ Branch 0 taken 758 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 758 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 758 times.
✗ Branch 5 not taken.
758 e = new eFire((zfix)x,(zfix)y,id,clk);
17480 758 break;
17481
17482 case eeOTHER:
17483
3/6
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7630 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7630 times.
✗ Branch 5 not taken.
7630 e = new eOther((zfix)x,(zfix)y,id,clk);
17484 7630 break;
17485
17486
17487 case eeSCRIPT01:
17488 case eeSCRIPT02:
17489 case eeSCRIPT03:
17490 case eeSCRIPT04:
17491 case eeSCRIPT05:
17492 case eeSCRIPT06:
17493 case eeSCRIPT07:
17494 case eeSCRIPT08:
17495 case eeSCRIPT09:
17496 case eeSCRIPT10:
17497 case eeSCRIPT11:
17498 case eeSCRIPT12:
17499 case eeSCRIPT13:
17500 case eeSCRIPT14:
17501 case eeSCRIPT15:
17502 case eeSCRIPT16:
17503 case eeSCRIPT17:
17504 case eeSCRIPT18:
17505 case eeSCRIPT19:
17506 case eeSCRIPT20:
17507 {
17508 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17509 {
17510 e = new eScript((zfix)x,(zfix)y,id,clk);
17511 break;
17512 }
17513 else return 0;
17514 }
17515
17516 case eeFFRIENDLY01:
17517 case eeFFRIENDLY02:
17518 case eeFFRIENDLY03:
17519 case eeFFRIENDLY04:
17520 case eeFFRIENDLY05:
17521 case eeFFRIENDLY06:
17522 case eeFFRIENDLY07:
17523 case eeFFRIENDLY08:
17524 case eeFFRIENDLY09:
17525 case eeFFRIENDLY10:
17526 {
17527 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17528 {
17529 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17530 }
17531 else return 0;
17532
17533 }
17534
17535 case eeSPINTILE:
17536
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17537 94 break;
17538
17539 // and these enemies use the misc10/misc2 value
17540 case eeROCK:
17541 {
17542
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 354 times.
384 switch(guysbuf[id&0xFFF].attributes[9])
17543 {
17544 case 1:
17545
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17546 30 break;
17547
17548 354 case 0:
17549 default:
17550
3/6
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 354 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 354 times.
✗ Branch 5 not taken.
354 e = new eRock((zfix)x,(zfix)y,id,clk);
17551 354 break;
17552 }
17553
17554 384 break;
17555 }
17556
17557 case eeTRAP:
17558 {
17559
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 1640 times.
2472 switch(guysbuf[id&0xFFF].attributes[1])
17560 {
17561 case 1:
17562
3/6
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
832 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17563 832 break;
17564
17565 1640 case 0:
17566 default:
17567
3/6
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1640 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1640 times.
✗ Branch 5 not taken.
1640 e = new eTrap((zfix)x,(zfix)y,id,clk);
17568 1640 break;
17569 }
17570
17571 2472 break;
17572 }
17573
17574 case eeDONGO:
17575 {
17576
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 203 times.
251 switch(guysbuf[id&0xFFF].attributes[9])
17577 {
17578 case 1:
17579
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17580 48 break;
17581
17582 203 case 0:
17583 default:
17584
3/6
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 203 times.
✗ Branch 5 not taken.
203 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17585 203 break;
17586 }
17587
17588 251 break;
17589 }
17590
17591 case eeDIG:
17592 {
17593
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 76 times.
403 switch(guysbuf[id&0xFFF].attributes[9])
17594 {
17595 case 1:
17596
3/6
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 327 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
327 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17597 327 break;
17598
17599 76 case 0:
17600 default:
17601
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17602 76 break;
17603 }
17604
17605 403 break;
17606 }
17607
17608 case eePATRA:
17609 {
17610
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 102 times.
292 switch(guysbuf[id&0xFFF].attributes[9])
17611 {
17612 case 1:
17613
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (get_qr(qr_HARDCODED_BS_PATRA))
17614 {
17615
3/6
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 102 times.
✗ Branch 5 not taken.
102 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17616 102 break;
17617 }
17618 [[fallthrough]];
17619 190 case 0:
17620 default:
17621
3/6
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 190 times.
✗ Branch 5 not taken.
190 e = new ePatra((zfix)x,(zfix)y,id,clk);
17622 190 break;
17623 }
17624
17625 292 break;
17626 }
17627
17628 case eeGUY:
17629 {
17630
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
5 switch(guysbuf[id&0xFFF].attributes[9])
17631 {
17632 case 1:
17633 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17634 break;
17635
17636 5 case 0:
17637 default:
17638
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 e = new eNPC((zfix)x,(zfix)y,id,clk);
17639 5 break;
17640 }
17641
17642 5 break;
17643 }
17644
17645 case eeNONE:
17646
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(guysbuf[id&0xFFF].attributes[9] ==1)
17647 {
17648
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17649 533 break;
17650 }
17651 [[fallthrough]];
17652 default:
17653
17654 return 0;
17655 }
17656
17657 102142 ret++; // Made one enemy.
17658
17659
4/4
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 101965 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 152 times.
102142 if(z && canfall(id))
17660 {
17661 152 e->z = (zfix)z;
17662 152 }
17663
17664
2/2
✓ Branch 0 taken 101965 times.
✓ Branch 1 taken 177 times.
102142 ((enemy*)e)->ceiling = (z && canfall(id));
17665
17666
1/2
✓ Branch 0 taken 102142 times.
✗ Branch 1 not taken.
102142 if(!guys.add(e))
17667 {
17668 return 0;
17669 }
17670
17671 // add segments of segmented enemies
17672 102142 int32_t c=0;
17673
17674
6/6
✓ Branch 0 taken 100495 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 149 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 292 times.
102142 switch(guysbuf[id&0xFFF].type)
17675 {
17676 case eeMOLD:
17677 {
17678 618 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17679 618 id &= 0xFFF;
17680
17681
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3768 times.
✓ Branch 2 taken 3768 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3768 times.
✓ Branch 6 taken 3150 times.
✓ Branch 7 taken 618 times.
3768 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17682 {
17683 //christ this is messy -DD
17684 3150 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17685
17686
4/8
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3150 times.
✗ Branch 7 not taken.
3150 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17687 {
17688 al_trace("Moldorm segment %d could not be created!\n",i+1);
17689
17690 for(int32_t j=0; j<i+1; j++)
17691 guys.del(guys.Count()-1);
17692
17693 return 0;
17694 }
17695
17696
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 2532 times.
3150 if(i>0)
17697 2532 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17698
17699 3150 ret++;
17700 3150 }
17701
17702 618 break;
17703 }
17704
17705 case eeLANM:
17706 {
17707 420 id &= 0xFFF;
17708 420 int32_t shft = guysbuf[id].attributes[1];
17709 420 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17710
17711
4/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
420 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17712 {
17713 al_trace("Lanmola segment 1 could not be created!\n");
17714 guys.del(guys.Count()-1);
17715 return 0;
17716 }
17717
17718 420 ret++;
17719
17720
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2267 times.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2267 times.
✓ Branch 6 taken 1847 times.
✓ Branch 7 taken 420 times.
2267 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17721 {
17722
4/8
✓ Branch 0 taken 1847 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1847 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1847 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1847 times.
✗ Branch 7 not taken.
1847 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17723 {
17724 al_trace("Lanmola segment %d could not be created!\n",i+1);
17725
17726 for(int32_t j=0; j<i+1; j++)
17727 guys.del(guys.Count()-1);
17728
17729 return 0;
17730 }
17731
17732 1847 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17733 1847 ret++;
17734 1847 }
17735 }
17736 420 break;
17737
17738 case eeMANHAN:
17739 149 id &= 0xFFF;
17740
17741
2/2
✓ Branch 0 taken 688 times.
✓ Branch 1 taken 149 times.
837 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17742 {
17743
4/8
✓ Branch 0 taken 688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 688 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 688 times.
✗ Branch 7 not taken.
688 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17744 {
17745 al_trace("Manhandla head %d could not be created!\n",i+1);
17746
17747 for(int32_t j=0; j<i+1; j++)
17748 {
17749 guys.del(guys.Count()-1);
17750 }
17751
17752 return 0;
17753 }
17754
17755 688 ret++;
17756 688 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17757 688 }
17758
17759 149 break;
17760
17761 case eeGLEEOK:
17762 {
17763 168 id &= 0xFFF;
17764 168 eGleeok* parent = (eGleeok*)e;
17765
17766
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 701 times.
✓ Branch 2 taken 669 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 669 times.
✓ Branch 6 taken 533 times.
✓ Branch 7 taken 168 times.
701 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17767 {
17768
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
17769
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(!guys.add(head))
17770 {
17771 al_trace("Gleeok head %d could not be created!\n",i+1);
17772
17773 for(int32_t j=0; j<i+1; j++)
17774 {
17775 guys.del(guys.Count()-1);
17776 }
17777
17778 return false;
17779 }
17780
17781 533 head->necktile=parent->necktile;
17782 533 head->dummy_int[1]=parent->necktile;
17783
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 112 times.
533 if(get_qr(qr_NEWENEMYTILES))
17784 {
17785 421 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
17786 421 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
17787 421 }
17788 else
17789 {
17790 112 head->dummy_int[2]=parent->necktile+1; //connected head tile
17791 112 head->dummy_int[3]=parent->necktile+2; //flying head tile
17792 }
17793 533 head->tile = head->dummy_int[2];
17794
17795 533 c-=guysbuf[id].attributes[3];
17796 533 ret++;
17797 533 }
17798 }
17799 168 break;
17800
17801
17802 case eePATRA:
17803 {
17804 292 id &= 0xFFF;
17805 292 int32_t outeyes = 0;
17806
17807
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2248 times.
✓ Branch 2 taken 1956 times.
✓ Branch 3 taken 292 times.
2248 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17808 {
17809
10/22
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✓ Branch 4 taken 612 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 612 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 612 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1344 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1344 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1344 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1344 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1956 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17810 {
17811 al_trace("Patra outer eye %d could not be created!\n",i+1);
17812
17813 for(int32_t j=0; j<i+1; j++)
17814 guys.del(guys.Count()-1);
17815
17816 return 0;
17817 }
17818 else
17819 1956 outeyes++;
17820
17821 1956 ret++;
17822 1956 }
17823
17824
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
✓ Branch 2 taken 312 times.
✓ Branch 3 taken 292 times.
604 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17825 {
17826
4/8
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 312 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 312 times.
✗ Branch 7 not taken.
312 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17827 {
17828 al_trace("Patra inner eye %d could not be created!\n",i+1);
17829
17830 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17831 guys.del(guys.Count()-1);
17832
17833 return 0;
17834 }
17835
17836 312 ret++;
17837 312 }
17838
17839 292 break;
17840 }
17841 }
17842
17843
2/2
✓ Branch 0 taken 111048 times.
✓ Branch 1 taken 102142 times.
213190 for (int i = 0; i < ret; i++)
17844 {
17845 111048 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17846 111048 e->screen_spawned = screen;
17847 111048 }
17848
17849 102142 return ret;
17850 102142 }
17851
17852 2059282 bool isjumper(int32_t id)
17853 {
17854
2/4
✓ Branch 0 taken 2059282 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2059282 times.
2059282 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17855 {
17856 return false;
17857 }
17858
3/3
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1953404 times.
✓ Branch 2 taken 105869 times.
2059282 switch(guysbuf[id&0xFFF].type)
17859 {
17860 case eeROCK:
17861 case eeTEK:
17862 9 return true;
17863
17864 case eeWALK:
17865
3/4
✓ Branch 0 taken 105869 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 93604 times.
105869 if(guysbuf[id&0xFFF].attributes[8] == e9tVIRE || guysbuf[id & 0xFFF].attributes[8] == e9tPOLSVOICE) return true;
17866 93604 }
17867
17868 2047008 return false;
17869 2059282 }
17870
17871
17872 8068 bool isfixedtogrid(int32_t id)
17873 {
17874
2/4
✓ Branch 0 taken 8068 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8068 times.
8068 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17875 {
17876 return false;
17877 }
17878
1/2
✓ Branch 0 taken 8068 times.
✗ Branch 1 not taken.
8068 switch(guysbuf[id&0xFFF].type)
17879 {
17880 case eeWALK:
17881 case eeLEV:
17882 case eeZORA:
17883 case eeDONGO:
17884 case eeGANON:
17885 case eeROCK:
17886 case eeGLEEOK:
17887 case eeAQUA:
17888 case eeLANM:
17889 return true;
17890 }
17891
17892 8068 return false;
17893 8068 }
17894
17895 // Can't fall, can have Z value.
17896 76161798 bool isflier(int32_t id)
17897 {
17898
3/4
✓ Branch 0 taken 76161798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110858 times.
✓ Branch 3 taken 76050940 times.
76161798 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17899 {
17900 110858 return false;
17901 }
17902
2/2
✓ Branch 0 taken 14067022 times.
✓ Branch 1 taken 61983918 times.
76050940 switch(guysbuf[id&0xFFF].type) //id&0x0FFF)
17903 {
17904 case eePEAHAT:
17905 case eeKEESE:
17906 case eePATRA:
17907 case eeFAIRY:
17908 case eeGHINI:
17909
17910 // Could theoretically have their Z set by a script
17911 case eeFIRE:
17912 14067022 return true;
17913 break;
17914 }
17915
17916 61983918 return false;
17917 76161798 }
17918
17919 // Can't have Z position
17920 4046103 bool never_in_air(int32_t id)
17921 {
17922
2/4
✓ Branch 0 taken 4046103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4046103 times.
4046103 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17923 {
17924 return false;
17925 }
17926
2/2
✓ Branch 0 taken 4036553 times.
✓ Branch 1 taken 9550 times.
4046103 switch(guysbuf[id&0xFFF].type)
17927 {
17928 case eeMANHAN:
17929 case eeMOLD:
17930 case eeLANM:
17931 case eeGLEEOK:
17932 case eeZORA:
17933 case eeLEV:
17934 case eeAQUA:
17935 case eeROCK:
17936 case eeGANON:
17937 case eeTRAP:
17938 case eePROJECTILE:
17939 case eeSPINTILE:
17940 9550 return true;
17941 }
17942
17943 4036553 return false;
17944 4046103 }
17945
17946 2248208 bool canfall(int32_t id)
17947 {
17948
3/4
✓ Branch 0 taken 2248208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 2248162 times.
2248208 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17949 {
17950 46 return false;
17951 }
17952
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2248122 times.
✓ Branch 2 taken 40 times.
2248162 switch(guysbuf[id&0xFFF].type)
17953 {
17954 case eeGUY:
17955 {
17956
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(id < eOCTO1S)
17957 40 return false;
17958
17959 switch(guysbuf[id&0xFFF].attributes[9])
17960 {
17961 case 1:
17962 case 2:
17963 return true;
17964
17965 case 0:
17966 case 3:
17967 default:
17968 return false;
17969 }
17970
17971 case eeGHOMA:
17972 case eeDIG:
17973 return false;
17974 }
17975 }
17976
17977
17978
4/4
✓ Branch 0 taken 2239686 times.
✓ Branch 1 taken 8436 times.
✓ Branch 2 taken 180404 times.
✓ Branch 3 taken 2059282 times.
2248122 return !never_in_air(id) && !isflier(id) && !isjumper(id);
17979 2248208 }
17980
17981 73903985 bool enemy::enemycanfall(int32_t id, bool checkgrav)
17982 {
17983
3/4
✓ Branch 0 taken 73903985 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89598 times.
✓ Branch 3 taken 73814387 times.
73903985 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17984 {
17985 89598 return false;
17986 }
17987 //Z_scripterrlog("canfall family is %d:\n", family);
17988 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & move_obeys_grav ? "true" : "false");
17989 //if ( family == eeFIRE && id >= eSTART )
17990 //{
17991 // Z_scripterrlog("eeFire\n");
17992 // return moveflags & move_obeys_grav; //'Other' enemy class, used by scripts. -Z
17993 //}
17994
17995 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
17996
17997
3/3
✓ Branch 0 taken 428935 times.
✓ Branch 1 taken 71307975 times.
✓ Branch 2 taken 2077477 times.
73814387 switch(guysbuf[id&0xFFF].type)
17998 {
17999 case eeGUY:
18000 {
18001
1/2
✓ Branch 0 taken 2077477 times.
✗ Branch 1 not taken.
2077477 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
18002 2077477 return false;
18003
18004 switch(guysbuf[id&0xFFF].attributes[9]) //I'm unsure what these specify off-hand. Needs better comments. -Z
18005 {
18006 case 1:
18007 case 2:
18008 return true;
18009
18010 case 0:
18011 case 3:
18012 default:
18013 return false;
18014 }
18015
18016 case eeGHOMA:
18017 case eeDIG:
18018 428935 return false;
18019 }
18020 }
18021
18022
2/2
✓ Branch 0 taken 39108925 times.
✓ Branch 1 taken 32199050 times.
71307975 if(!checkgrav) return true;
18023 39108925 return (moveflags & move_obeys_grav);
18024
18025 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
18026 // {
18027 // if ( moveflags & move_obeys_grav ) return true;
18028 // else return false;
18029 // }
18030 // else
18031 // {
18032 // return (moveflags & move_obeys_grav);
18033 // }
18034 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
18035 73903985 }
18036
18037 1271 void addfires()
18038 {
18039
2/2
✓ Branch 0 taken 814 times.
✓ Branch 1 taken 457 times.
1271 if(!get_qr(qr_NOGUYFIRES))
18040 {
18041 2285 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
18042 457 int32_t bs = get_qr(qr_BSZELDA);
18043 914 addguy(dx+(bs? 64: 72),dy+64,gFIRE,-17,false,nullptr);
18044 914 addguy(dx+(bs?176:168),dy+64,gFIRE,-18,false,nullptr);
18045 457 }
18046 1271 }
18047
18048 // This function runs one time for every screen on the first frame of a region being loaded.
18049 // It handles spawning screen guys (not the enemies), item, and room-specific sprites.
18050 37028 static void loadguys(mapscr* scr)
18051 {
18052 37028 int screen = scr->screen;
18053 37028 byte Guy=0;
18054 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
18055 // Else use mITEM and ipONETIME
18056 37028 int32_t mf = (screen>=128) ? mSPECIALITEM : mITEM;
18057 37028 int32_t onetime = (screen>=128) ? ipONETIME2 : ipONETIME;
18058
18059 37028 mapscr* guyscr = scr;
18060
4/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 36122 times.
✓ Branch 2 taken 475 times.
✓ Branch 3 taken 431 times.
37028 if(screen>=128 && DMaps[cur_dmap].flags&dmfGUYCAVES)
18061 {
18062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431 times.
431 if(DMaps[cur_dmap].flags&dmfCAVES)
18063 {
18064 431 Guy=special_warp_return_scr->guy;
18065 431 guyscr = special_warp_return_scr;
18066 431 }
18067 431 }
18068 else
18069 {
18070 36597 Guy=scr->guy;
18071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36597 times.
36597 if (game->get_regionmapping() == REGION_MAPPING_FULL)
18072 36597 mark_visited(screen);
18073 }
18074
18075 114000 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
18076
18077 37028 bool oldguy = get_qr(qr_OLD_GUY_HANDLING);
18078 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
18079
4/4
✓ Branch 0 taken 3865 times.
✓ Branch 1 taken 33163 times.
✓ Branch 2 taken 2550 times.
✓ Branch 3 taken 1315 times.
37028 if(Guy && ((screen>=128) == !!(DMaps[cur_dmap].flags&dmfGUYCAVES)))
18080 {
18081
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1304 times.
1315 if(scr->room==rZELDA)
18082 {
18083 22 addguy(dx+120,dy+72,Guy,-15,true,guyscr);
18084 11 guys.spr(0)->hxofs=1000;
18085 33 addenemy(screen,dx+128,dy+96,eFIRE,-15);
18086 33 addenemy(screen,dx+112,dy+96,eFIRE,-15);
18087 33 addenemy(screen,dx+96,dy+120,eFIRE,-15);
18088 33 addenemy(screen,dx+144,dy+120,eFIRE,-15);
18089 11 return;
18090 }
18091
18092
2/2
✓ Branch 0 taken 1300 times.
✓ Branch 1 taken 4 times.
2604 bool ffire = oldguy
18093
2/2
✓ Branch 0 taken 1271 times.
✓ Branch 1 taken 29 times.
1300 ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES))
18094 4 : (guyscr->roomflags&RFL_GUYFIRES);
18095
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1271 times.
1304 if(ffire)
18096 1271 addfires();
18097
18098
2/2
✓ Branch 0 taken 879 times.
✓ Branch 1 taken 425 times.
1304 if(screen>=128)
18099
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 412 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
438 if(getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))
18100 13 Guy=0;
18101
18102
4/6
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 1091 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 45 times.
1304 switch(scr->room)
18103 {
18104 case rSP_ITEM:
18105 case rGRUMBLE:
18106 case rBOMBS:
18107 case rARROWS:
18108 case rSWINDLE:
18109 case rMUPGRADE:
18110 case rLEARNSLASH:
18111 case rTAKEONE:
18112
8/8
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 49 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 42 times.
167 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18113 55 Guy=0;
18114
18115 167 break;
18116
18117 case rREPAIR:
18118 if (get_qr(qr_OLD_DOORREPAIR)) break;
18119 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18120 Guy=0;
18121
18122 break;
18123 case rRP_HC:
18124 if (get_qr(qr_OLD_POTION_OR_HC)) break;
18125 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18126 Guy=0;
18127
18128 break;
18129 case rMONEY:
18130
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (get_qr(qr_OLD_SECRETMONEY)) break;
18131 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18132 Guy=0;
18133
18134 break;
18135
18136 case rTRIFORCE:
18137 {
18138 45 int32_t tc = TriforceCount();
18139
18140
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 34 times.
45 if(get_qr(qr_4TRI))
18141 {
18142
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_qr(qr_3TRI) && tc>=3) || tc>=4)
18143 10 Guy=0;
18144 9 }
18145 else
18146 {
18147
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 1 times.
34 if((get_qr(qr_3TRI) && tc>=6) || tc>=8)
18148 33 Guy=0;
18149 }
18150 }
18151 43 break;
18152 }
18153
18154
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 1195 times.
1302 if(Guy)
18155 {
18156
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1162 times.
1195 if(ffire)
18157 1162 blockpath=true;
18158
18159
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 783 times.
1195 if(screen<128)
18160 783 sfx(WAV_SCALE);
18161
18162
6/6
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 728 times.
✓ Branch 2 taken 467 times.
✓ Branch 3 taken 728 times.
✓ Branch 4 taken 110 times.
✓ Branch 5 taken 357 times.
2390 addguy(dx+120,dy+64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true, guyscr);
18163 1195 Hero.Freeze();
18164 1195 }
18165 1302 }
18166
5/6
✓ Branch 0 taken 33904 times.
✓ Branch 1 taken 1809 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 33833 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1809 times.
35713 else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
18167 {
18168 71 sfx(WAV_SCALE);
18169 142 addguy(dx+120,dy+62,gFAIRY,-14,false,guyscr);
18170 71 }
18171
18172 111045 loaditem(scr, dx, dy);
18173
18174 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
18175 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
18176
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 36996 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 15 times.
37015 if (scr->room==r10RUPIES && !getmapflag(screen, mf))
18177 {
18178
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 15 times.
165 for(int32_t i=0; i<10; i++)
18179 300 additem(dx+ten_rupies_x[i],dy+ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
18180 15 }
18181 37026 }
18182
18183 35784 void loadguys()
18184 {
18185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35784 times.
35784 if (loaded_guys)
18186 return;
18187
18188 35784 loaded_guys = true;
18189 35784 repaircharge = 0;
18190 35784 adjustmagic = false;
18191 35784 learnslash = false;
18192
2/2
✓ Branch 0 taken 107352 times.
✓ Branch 1 taken 35784 times.
143136 for (int32_t i=0; i<3; i++)
18193 {
18194 107352 prices[i] = 0;
18195 107352 }
18196
18197 72812 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18198 37028 get_screen_state(scr->screen).item_state = ScreenItemState::None;
18199 37028 loadguys(scr);
18200 37028 });
18201 35784 }
18202
18203 37034 void loaditem(mapscr* scr, int offx, int offy)
18204 {
18205 37034 int screen = scr->screen;
18206 37034 byte Item = 0;
18207
18208
2/2
✓ Branch 0 taken 36128 times.
✓ Branch 1 taken 906 times.
37034 if(screen<128)
18209 {
18210 36128 Item=scr->item;
18211
18212
4/4
✓ Branch 0 taken 1593 times.
✓ Branch 1 taken 34535 times.
✓ Branch 2 taken 32910 times.
✓ Branch 3 taken 3218 times.
36128 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
18213 {
18214
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3159 times.
3218 if(scr->flags8&fSECRETITEM)
18215 59 screen_item_set_state(screen, ScreenItemState::WhenTriggerSecrets);
18216
2/2
✓ Branch 0 taken 1164 times.
✓ Branch 1 taken 1995 times.
3159 else if(scr->flags&fITEM)
18217 1164 screen_item_set_state(screen, ScreenItemState::WhenKillEnemies);
18218
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 1886 times.
1995 else if(scr->flags11&efCARRYITEM)
18219 109 screen_item_set_state(screen, ScreenItemState::MustGiveToEnemy); // Will be set to CarriedByEnemy in roaming_item
18220 else
18221 {
18222 1886 int x = scr->itemx;
18223
3/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1871 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
1886 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18224 -170 :
18225 1886 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18226
3/6
✓ Branch 0 taken 1886 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1886 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1886 times.
✗ Branch 5 not taken.
3772 add_item_for_screen(screen, new item(offx + x, offy + y,
18227
6/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1871 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1871 times.
✗ Branch 9 not taken.
1886 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18228
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 1781 times.
1886 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].type==itype_triforcepiece ||
18229 1886 (scr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18230 }
18231 3218 }
18232 36128 }
18233
2/2
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 475 times.
906 else if(!(DMaps[cur_dmap].flags&dmfCAVES))
18234 {
18235
4/6
✓ Branch 0 taken 475 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 469 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
491 if((!getmapflag(screen, (screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (special_warp_return_scr->flags9&fBELOWRETURN)) && special_warp_return_scr->room==rSP_ITEM
18236
4/4
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 147 times.
475 && (screen==128 || !get_qr(qr_ITEMSINPASSAGEWAYS)))
18237 {
18238 163 Item = special_warp_return_scr->catchall;
18239
18240
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 162 times.
163 if(Item)
18241 {
18242 162 int x = scr->itemx;
18243
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18244 -170 :
18245 162 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18246
3/6
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162 times.
✗ Branch 5 not taken.
324 add_item_for_screen(screen, new item(offx + x, offy + y,
18247
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
162 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18248 162 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18249 162 }
18250 163 }
18251 475 }
18252 37034 }
18253
18254 957 void never_return(int32_t screen, int32_t index)
18255 {
18256
2/2
✓ Branch 0 taken 766 times.
✓ Branch 1 taken 191 times.
957 if(!get_qr(qr_KILLALL))
18257 191 goto doit;
18258
18259
2/2
✓ Branch 0 taken 2292 times.
✓ Branch 1 taken 329 times.
2621 for(int32_t i=0; i<guys.Count(); i++)
18260
4/4
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 1312 times.
✓ Branch 2 taken 543 times.
✓ Branch 3 taken 437 times.
2292 if(((((enemy*)guys.spr(i))->d->flags)&guy_never_return) && i!=index)
18261 {
18262 437 goto dontdoit;
18263 329 }
18264
18265 doit:
18266 520 setmapflag(get_scr(screen), mNEVERRET);
18267 dontdoit:
18268 957 return;
18269 }
18270
18271 63753 bool slowguy(int32_t id)
18272 {
18273
2/4
✓ Branch 0 taken 63753 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63753 times.
63753 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18274 {
18275 return false;
18276 }
18277
18278 63753 id = id&0xFFF;
18279
18280
2/2
✓ Branch 0 taken 54110 times.
✓ Branch 1 taken 9643 times.
63753 switch(id)
18281 {
18282 case eOCTO1S:
18283 case eOCTO2S:
18284 case eOCTO1F:
18285 case eOCTO2F:
18286 case eLEV1:
18287 case eLEV2:
18288 case eROCK:
18289 case eBOULDER:
18290 9643 return true;
18291 }
18292
18293 54110 return false;
18294 63753 }
18295
18296 83364 static bool ok2add(mapscr* scr, int32_t id)
18297 {
18298
2/4
✓ Branch 0 taken 83364 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 83364 times.
83364 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18299 {
18300 return false;
18301 }
18302
18303 83364 id = id&0xFFF;
18304
18305
4/4
✓ Branch 0 taken 829 times.
✓ Branch 1 taken 82535 times.
✓ Branch 2 taken 464 times.
✓ Branch 3 taken 365 times.
83364 if(getmapflag(scr, mNEVERRET) && (guysbuf[id].flags & guy_never_return))
18306 464 return false;
18307
18308
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 82259 times.
✓ Branch 2 taken 376 times.
✓ Branch 3 taken 201 times.
82900 switch(guysbuf[id].type)
18309 {
18310 // I added a special case for shooters because having traps on the same screen
18311 // was preventing them from spawning due to TMPNORET. This means they will
18312 // never stay dead, though, so it may not be the best solution. - Saf
18313 case eePROJECTILE:
18314 376 return true;
18315
18316
18317 case eeDIG:
18318 {
18319
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 75 times.
201 switch(guysbuf[id].attributes[9])
18320 {
18321 case 1:
18322
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 47 times.
126 if(!get_qr(qr_NOTMPNORET))
18323 79 return !getmapflag(scr, mTMPNORET);
18324
18325 47 return true;
18326
18327 75 case 0:
18328 default:
18329 75 return true;
18330 }
18331 }
18332 case eeGANON:
18333 case eeTRAP:
18334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
128 if ((guysbuf[id].type == eeGANON && !get_qr(qr_CAN_PLACE_GANON))
18335
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
64 || (guysbuf[id].type == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false;
18336 [[fallthrough]];
18337 default:
18338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82259 times.
82259 if (guysbuf[id].flags&guy_ignoretmpnr) return true;
18339 82259 break;
18340 }
18341
18342
2/2
✓ Branch 0 taken 20978 times.
✓ Branch 1 taken 61281 times.
82259 if(!get_qr(qr_NOTMPNORET))
18343 61281 return !getmapflag(scr, mTMPNORET);
18344
18345 20978 return true;
18346 83364 }
18347
18348 1634105 static void activate_fireball_statue(const rpos_handle_t& rpos_handle)
18349 {
18350
3/4
✓ Branch 0 taken 288841 times.
✓ Branch 1 taken 1345264 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 288841 times.
1634105 if (!(rpos_handle.scr->flags11&efFIREBALLS) || statueID<0)
18351 {
18352 1345264 return;
18353 }
18354
18355 288841 int32_t ctype = rpos_handle.ctype();
18356
6/6
✓ Branch 0 taken 287333 times.
✓ Branch 1 taken 1508 times.
✓ Branch 2 taken 286018 times.
✓ Branch 3 taken 1315 times.
✓ Branch 4 taken 1213 times.
✓ Branch 5 taken 284805 times.
288841 if (ctype != cL_STATUE && ctype != cR_STATUE && ctype != cC_STATUE) return;
18357
18358 12108 auto [x, y] = rpos_handle.xy();
18359
18360 4036 int32_t cx=-1000, cy=-1000;
18361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4036 times.
4036 if(!isfixedtogrid(statueID))
18362 {
18363
2/2
✓ Branch 0 taken 1508 times.
✓ Branch 1 taken 2528 times.
4036 if(ctype==cL_STATUE)
18364 {
18365 1508 cx=x+4;
18366 1508 cy=y+7;
18367 1508 }
18368
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 1213 times.
2528 else if(ctype==cR_STATUE)
18369 {
18370 1315 cx=x-8;
18371 1315 cy=y-1;
18372 1315 }
18373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1213 times.
1213 else if(ctype==cC_STATUE)
18374 {
18375 1213 cx=x;
18376 1213 cy=y;
18377 1213 }
18378 4036 }
18379 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
18380 {
18381 cx=x;
18382 cy=y;
18383 }
18384
18385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4036 times.
4036 if(cx!=-1000) // No point creating it if this is false
18386 {
18387
2/2
✓ Branch 0 taken 9754 times.
✓ Branch 1 taken 4032 times.
13786 for(int32_t j=0; j<guys.Count(); j++)
18388 {
18389
4/4
✓ Branch 0 taken 1698 times.
✓ Branch 1 taken 8056 times.
✓ Branch 2 taken 1694 times.
✓ Branch 3 taken 4 times.
9754 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
18390 {
18391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
18392 4 return; // No point deleting it. A script might be toying with it in some way.
18393 else
18394 guys.del(j);
18395 }
18396 9750 }
18397
18398 4032 addenemy(rpos_handle.screen, cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
18399 4032 }
18400 1634105 }
18401
18402 34365 static void activate_fireball_statues(mapscr* scr)
18403 {
18404
2/2
✓ Branch 0 taken 32946 times.
✓ Branch 1 taken 1419 times.
34365 if (!(scr->flags11&efFIREBALLS))
18405 {
18406 32946 return;
18407 }
18408
18409 251163 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18410 249744 activate_fireball_statue(rpos_handle);
18411 249744 });
18412 34365 }
18413
18414 35048 void load_default_enemies(mapscr* scr)
18415 {
18416 35048 int screen = scr->screen;
18417 40513 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
18418
18419 35048 wallm_load_clk=frame-80;
18420
18421
2/2
✓ Branch 0 taken 33152 times.
✓ Branch 1 taken 1896 times.
35048 if(scr->flags11&efZORA)
18422 {
18423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1896 times.
1896 if(zoraID>=0)
18424 5688 addenemy(screen, dx - 16, dy - 16, zoraID, 0);
18425 1896 }
18426
18427
2/2
✓ Branch 0 taken 34870 times.
✓ Branch 1 taken 178 times.
35048 if(scr->flags11&efTRAP4)
18428 {
18429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 if(cornerTrapID>=0)
18430 {
18431 534 addenemy(screen, dx + 32, dy + 32, cornerTrapID, -14);
18432 534 addenemy(screen, dx + 208, dy + 32, cornerTrapID, -14);
18433 534 addenemy(screen, dx + 32, dy + 128, cornerTrapID, -14);
18434 534 addenemy(screen, dx + 208, dy + 128, cornerTrapID, -14);
18435 178 }
18436 178 }
18437
18438 6203496 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18439 6168448 int32_t ctype = rpos_handle.ctype();
18440 6168448 int32_t cflag = rpos_handle.sflag();
18441 6168448 int32_t cflag_i = rpos_handle.cflag();
18442
18443
4/6
✓ Branch 0 taken 6168448 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6168102 times.
✓ Branch 3 taken 346 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6168102 times.
6168448 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
18444 {
18445 346 auto [x, y] = rpos_handle.xy();
18446
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 336 times.
346 if(trapLOSHorizontalID>=0)
18447 1008 addenemy(screen, x, y, trapLOSHorizontalID, -14);
18448 346 }
18449
4/6
✓ Branch 0 taken 6168102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6167896 times.
✓ Branch 3 taken 206 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6167896 times.
6168102 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
18450 {
18451 206 auto [x, y] = rpos_handle.xy();
18452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(trapLOSVerticalID>=0)
18453 618 addenemy(screen, x, y, trapLOSVerticalID, -14);
18454 206 }
18455
4/6
✓ Branch 0 taken 6167896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6167618 times.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6167618 times.
6167896 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
18456 {
18457 278 auto [x, y] = rpos_handle.xy();
18458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(trapLOS4WayID>=0)
18459 {
18460
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 278 times.
834 if(addenemy(screen, x, y, trapLOS4WayID, -14))
18461 278 guys.spr(guys.Count()-1)->dummy_int[1]=2;
18462 278 }
18463 278 }
18464
4/6
✓ Branch 0 taken 6167618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6167219 times.
✓ Branch 3 taken 399 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6167219 times.
6167618 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
18465 {
18466 399 auto [x, y] = rpos_handle.xy();
18467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if(trapConstantHorizontalID>=0)
18468 1197 addenemy(screen, x, y, trapConstantHorizontalID, -14);
18469 399 }
18470
4/6
✓ Branch 0 taken 6167219 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6166786 times.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6166786 times.
6167219 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
18471 {
18472 433 auto [x, y] = rpos_handle.xy();
18473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if(trapConstantVerticalID>=0)
18474 1299 addenemy(screen, x, y, trapConstantVerticalID, -14);
18475 433 }
18476
18477
1/2
✓ Branch 0 taken 6168448 times.
✗ Branch 1 not taken.
6168448 if(ctype==cSPINTILE1)
18478 {
18479 awaken_spinning_tile(rpos_handle);
18480 }
18481 6168448 });
18482
18483
2/2
✓ Branch 0 taken 34992 times.
✓ Branch 1 taken 56 times.
35048 if(scr->flags11&efTRAP2)
18484 {
18485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(centerTrapID>=-1)
18486 {
18487
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(addenemy(screen, 64, 80, centerTrapID, -14))
18488 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18489
18490
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(addenemy(screen, 176, 80, centerTrapID, -14))
18491 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18492 56 }
18493 56 }
18494
18495
2/2
✓ Branch 0 taken 34965 times.
✓ Branch 1 taken 83 times.
35048 if(scr->flags11&efROCKS)
18496 {
18497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(rockID>=0)
18498 {
18499 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18500 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18501 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18502 83 }
18503 83 }
18504 35048 }
18505
18506 #define SLOPE_STAGE_COMBOS 0
18507 #define SLOPE_STAGE_FFCS 1
18508 #define SLOPE_STAGE_COMBOS_BORDERING_SCREENS 2
18509
18510 20910624 static slope_id_t create_slope_id(int stage, int arg1, int arg2)
18511 {
18512
2/2
✓ Branch 0 taken 4645463 times.
✓ Branch 1 taken 16265161 times.
20910624 if (stage == SLOPE_STAGE_COMBOS)
18513 16265161 return (region_num_rpos*arg1)+arg2;
18514
2/2
✓ Branch 0 taken 4500554 times.
✓ Branch 1 taken 144909 times.
4645463 if (stage == SLOPE_STAGE_FFCS)
18515 4500554 return (region_num_rpos*7)+arg1;
18516
1/2
✓ Branch 0 taken 144909 times.
✗ Branch 1 not taken.
144909 if (stage == SLOPE_STAGE_COMBOS_BORDERING_SCREENS)
18517 144909 return (region_num_rpos*7 + MAX_FFCID+1)+arg1*7*(16 * 2 + 11 * 2) + arg2;
18518 // TODO: what about FFCs from bordering screens?
18519
18520 assert(false);
18521 return 0;
18522 20910624 }
18523
18524 16265161 void update_slope_combopos(const rpos_handle_t& rpos_handle)
18525 {
18526 16265161 mapscr* s = rpos_handle.scr;
18527 16265161 auto& cmb = rpos_handle.combo();
18528
18529 16265161 auto id = create_slope_id(SLOPE_STAGE_COMBOS, rpos_handle.layer, (int)rpos_handle.rpos);
18530 16265161 auto it = slopes.find(id);
18531
18532 16265161 bool wasSlope = it!=slopes.end();
18533 16265161 bool isSlope = cmb.type == cSLOPE;
18534
18535
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 16265025 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
16265161 if(isSlope && !wasSlope)
18536 {
18537 272 auto [x, y] = rpos_handle.xy();
18538 272 slopes.try_emplace(id, &(s->data[rpos_handle.pos]), nullptr, -1, x, y);
18539 136 }
18540
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16265025 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16265025 else if(wasSlope && !isSlope)
18541 {
18542 slopes.erase(it);
18543 }
18544 16265161 }
18545
18546 144909 static void update_slope_combopos_bordering_screen(int dir, int slope_count, int cid, bool is_slope, int offx, int offy)
18547 {
18548 144909 auto id = create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS, dir, slope_count);
18549 144909 auto it = slopes.find(id);
18550
18551 144909 bool wasSlope = it!=slopes.end();
18552 144909 bool isSlope = is_slope;
18553
18554
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144909 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144909 if(isSlope && !wasSlope)
18555 {
18556 static std::vector<word> TMP;
18557 int num_border_combos = cur_region.screen_width*16 * 2 + cur_region.screen_height*11 * 2;
18558 TMP.resize(num_border_combos * 7 * 4);
18559
18560 int tmp_index = id-create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS,0,0);
18561 TMP[tmp_index] = cid;
18562 slopes.try_emplace(id, &TMP[tmp_index], nullptr, -1, offx, offy);
18563 }
18564
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144909 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144909 else if(wasSlope && !isSlope)
18565 {
18566 slopes.erase(it);
18567 }
18568 144909 }
18569
18570 // Load a single column or row from a nearby screen, and load its slopes.
18571 3884 static void handle_slope_combopos_bordering_screen(int initial_screen, int dir)
18572 {
18573 55866 auto [map, screen] = nextscr2(cur_map, initial_screen, dir);
18574
2/2
✓ Branch 0 taken 3713 times.
✓ Branch 1 taken 171 times.
3884 if (map == -1)
18575 171 return;
18576
18577 3713 int offx = 0;
18578 3713 int offy = 0;
18579
2/2
✓ Branch 0 taken 2800 times.
✓ Branch 1 taken 913 times.
3713 if (dir == up)
18580 913 offy = -16;
18581
2/2
✓ Branch 0 taken 862 times.
✓ Branch 1 taken 1938 times.
2800 else if (dir == down)
18582 862 offy = world_h;
18583
2/2
✓ Branch 0 taken 968 times.
✓ Branch 1 taken 970 times.
1938 else if (dir == left)
18584 968 offx = -16;
18585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 970 times.
970 else if (dir == right)
18586 970 offx = world_w;
18587
18588
2/2
✓ Branch 0 taken 3713 times.
✓ Branch 1 taken 25991 times.
29704 for (int layer = 0; layer < 7; layer++)
18589 {
18590 51982 auto scr = load_temp_mapscr_and_apply_secrets(map, screen, layer - 1, true, false);
18591
2/2
✓ Branch 0 taken 10824 times.
✓ Branch 1 taken 15167 times.
25991 if (!scr) continue;
18592
18593 10824 int slope_count = layer * (16*2);
18594
18595
4/4
✓ Branch 0 taken 7999 times.
✓ Branch 1 taken 2825 times.
✓ Branch 2 taken 2830 times.
✓ Branch 3 taken 5169 times.
10824 if (dir == left || dir == right)
18596 {
18597 5655 int x = dir == left ? 15 : 0;
18598
2/2
✓ Branch 0 taken 62205 times.
✓ Branch 1 taken 5655 times.
67860 for (int y = 0; y < 11; y++)
18599 {
18600 62205 int pos = y * 16 + x;
18601 62205 int cid = scr->data[pos];
18602 62205 bool is_slope = combobuf[cid].type == cSLOPE;
18603
1/2
✓ Branch 0 taken 62205 times.
✗ Branch 1 not taken.
62205 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx, offy + y*16);
18604 62205 }
18605 5655 }
18606
3/4
✓ Branch 0 taken 2494 times.
✓ Branch 1 taken 2675 times.
✓ Branch 2 taken 2494 times.
✗ Branch 3 not taken.
5169 else if (dir == up || dir == down)
18607 {
18608 5169 int y = dir == up ? 10 : 0;
18609
2/2
✓ Branch 0 taken 82704 times.
✓ Branch 1 taken 5169 times.
87873 for (int x = 0; x < 16; x++)
18610 {
18611 82704 int pos = y * 16 + x;
18612 82704 int cid = scr->data[pos];
18613 82704 bool is_slope = combobuf[cid].type == cSLOPE;
18614
1/2
✓ Branch 0 taken 82704 times.
✗ Branch 1 not taken.
82704 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx + x*16, offy);
18615 82704 }
18616 5169 }
18617
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 15167 times.
✓ Branch 2 taken 10824 times.
25991 }
18618 3884 }
18619
18620 35854 void update_slope_comboposes()
18621 {
18622 14916654 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18623 14880800 update_slope_combopos(rpos_handle);
18624 14880800 });
18625
18626
2/2
✓ Branch 0 taken 34883 times.
✓ Branch 1 taken 971 times.
35854 if (Hero.sideview_mode())
18627 {
18628 1942 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18629
2/2
✓ Branch 0 taken 3884 times.
✓ Branch 1 taken 971 times.
4855 for (int dir = up; dir <= right; dir++)
18630 3884 handle_slope_combopos_bordering_screen(scr->screen, dir);
18631 971 });
18632 971 }
18633
18634 35854 update_slopes();
18635 35854 }
18636
18637 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
18638 1384361 void screen_combo_modify_preroutine(const rpos_handle_t& rpos_handle)
18639 {
18640 1384361 delete_fireball_shooter(rpos_handle);
18641 1384361 }
18642
18643 //Placeholder in case we need it.
18644 void screen_ffc_modify_preroutine(const ffc_handle_t& ffc_handle)
18645 {
18646 return;
18647 }
18648
18649 // Everything that must be done after we change a screen's combo to another combo. -L
18650 1384361 void screen_combo_modify_postroutine(const rpos_handle_t& rpos_handle)
18651 {
18652 1384361 rpos_handle.scr->valid |= mVALID;
18653 1384361 activate_fireball_statue(rpos_handle);
18654
18655
2/2
✓ Branch 0 taken 1384267 times.
✓ Branch 1 taken 94 times.
1384361 if(rpos_handle.ctype()==cSPINTILE1)
18656 {
18657 94 awaken_spinning_tile(rpos_handle);
18658 94 }
18659
18660 1384361 update_slope_combopos(rpos_handle);
18661 1384361 }
18662
18663 4500554 void screen_ffc_modify_postroutine(const ffc_handle_t& ffc_handle)
18664 {
18665 4500554 ffcdata* ff = ffc_handle.ffc;
18666 4500554 auto& cmb = ffc_handle.combo();
18667
18668 4500554 auto id = create_slope_id(SLOPE_STAGE_FFCS, ffc_handle.id, -1);
18669 4500554 auto it = slopes.find(id);
18670
18671 4500554 bool wasSlope = it!=slopes.end();
18672
1/2
✓ Branch 0 taken 4500554 times.
✗ Branch 1 not taken.
4500554 bool isSlope = cmb.type == cSLOPE && !(ff->flags&ffc_changer);
18673
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4500554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4500554 if(isSlope && !wasSlope)
18674 {
18675 slopes.try_emplace(id, nullptr, ff, ffc_handle.id);
18676 }
18677
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4500554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4500554 else if(wasSlope && !isSlope)
18678 {
18679 slopes.erase(it);
18680 }
18681
18682 4500554 ffc_handle.scr->ffcCountMarkDirty();
18683 4500554 }
18684
18685 4414 void screen_combo_modify_pre(int32_t cid)
18686 {
18687 2813022 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18688
2/2
✓ Branch 0 taken 2803413 times.
✓ Branch 1 taken 5195 times.
2808608 if (rpos_handle.data() == cid)
18689 {
18690 5195 screen_combo_modify_preroutine(rpos_handle);
18691 5195 }
18692 2808608 });
18693 4414 }
18694 4414 void screen_combo_modify_post(int32_t cid)
18695 {
18696 4414 combo_caches::refresh(cid);
18697
18698 2813022 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18699
2/2
✓ Branch 0 taken 2803413 times.
✓ Branch 1 taken 5195 times.
2808608 if (rpos_handle.data() == cid)
18700 {
18701 5195 screen_combo_modify_postroutine(rpos_handle);
18702 5195 }
18703 2808608 });
18704
18705 144186 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
18706
2/2
✓ Branch 0 taken 139714 times.
✓ Branch 1 taken 58 times.
139772 if (ffc_handle.data() == cid)
18707 {
18708 58 screen_ffc_modify_postroutine(ffc_handle);
18709 58 }
18710 139772 });
18711 4414 }
18712
18713 94 void awaken_spinning_tile(const rpos_handle_t& rpos_handle)
18714 {
18715 94 int cid = rpos_handle.data();
18716 94 int cset = rpos_handle.cset();
18717 282 auto [x, y] = rpos_handle.xy();
18718
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
282 addenemy(rpos_handle.screen, x, y, (cset<<12)+eSPINTILE1, combobuf[cid].o_tile + zc_max(1,combobuf[cid].frames));
18719 94 }
18720
18721 // It stands for next_side_pos
18722 // moves sle_x and sle_y to the next position
18723 11464 void nsp(bool random)
18724 {
18725
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 8203 times.
11464 if(random)
18726 {
18727
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
18728 {
18729 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
18730 1634 sle_y = (zc_oldrand()%10)*16;
18731 1634 }
18732 else
18733 {
18734 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
18735 1627 sle_x = (zc_oldrand()%15)*16;
18736 }
18737
18738 3261 return;
18739 }
18740
18741
2/2
✓ Branch 0 taken 6168 times.
✓ Branch 1 taken 2035 times.
8203 if(sle_x==0)
18742 {
18743
2/2
✓ Branch 0 taken 1855 times.
✓ Branch 1 taken 180 times.
2035 if(sle_y<160)
18744 1855 sle_y+=16;
18745 else
18746 180 sle_x+=16;
18747 2035 }
18748
2/2
✓ Branch 0 taken 2596 times.
✓ Branch 1 taken 3572 times.
6168 else if(sle_y==160)
18749 {
18750
2/2
✓ Branch 0 taken 2430 times.
✓ Branch 1 taken 166 times.
2596 if(sle_x<240)
18751 2430 sle_x+=16;
18752 else
18753 166 sle_y-=16;
18754 2596 }
18755
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 2020 times.
3572 else if(sle_x==240)
18756 {
18757
2/2
✓ Branch 0 taken 1404 times.
✓ Branch 1 taken 148 times.
1552 if(sle_y>0)
18758 1404 sle_y-=16;
18759 else
18760 148 sle_x-=16;
18761 1552 }
18762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2020 times.
2020 else if(sle_y==0)
18763 {
18764
1/2
✓ Branch 0 taken 2020 times.
✗ Branch 1 not taken.
2020 if(sle_x>0)
18765 2020 sle_x-=16;
18766 else
18767 sle_y+=16;
18768 2020 }
18769 11464 }
18770
18771 // moves sle_x and sle_y to the next available position
18772 // returns the direction the enemy should face
18773 2429 int32_t next_side_pos(int32_t screen, bool random)
18774 {
18775 bool blocked;
18776 2429 int32_t c=0;
18777 25357 auto [offx, offy] = translate_screen_coordinates_to_world(screen);
18778
18779 2429 do
18780 {
18781
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 11333 times.
11464 nsp(c>35 ? false : random);
18782 22928 int x = sle_x + offx;
18783 22928 int y = sle_y + offy;
18784
4/4
✓ Branch 0 taken 2447 times.
✓ Branch 1 taken 9017 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 2428 times.
13892 blocked = _walkflag(x,y,2) || _walkflag(x,y+8,2) ||
18785
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 (combo_class_buf[COMBOTYPE(x,y)].block_enemies ||
18786
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2428 times.
✗ Branch 3 not taken.
2428 MAPFLAG(x,y) == mfNOENEMY || MAPCOMBOFLAG(x,y)==mfNOENEMY ||
18787
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2428 times.
2428 MAPFLAG(x,y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(x,y)==mfNOGROUNDENEMY ||
18788 2428 iswaterex_z3(MAPCOMBO(x,y), -1, x, y, true));
18789
18790
2/2
✓ Branch 0 taken 11463 times.
✓ Branch 1 taken 1 times.
11464 if(++c>50)
18791 1 return -1;
18792
2/2
✓ Branch 0 taken 9035 times.
✓ Branch 1 taken 2428 times.
11463 }
18793 11463 while(blocked);
18794
18795 2428 int32_t dir=0;
18796
18797
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 736 times.
2428 if(sle_x==0) dir=right;
18798
18799
2/2
✓ Branch 0 taken 1859 times.
✓ Branch 1 taken 569 times.
2428 if(sle_y==0) dir=down;
18800
18801
2/2
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 708 times.
2428 if(sle_x==240) dir=left;
18802
18803
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 if(sle_y==168) dir=up;
18804
18805 2428 return dir;
18806 2429 }
18807
18808 bool can_side_load(int32_t id)
18809 {
18810 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18811 {
18812 return false;
18813 }
18814
18815 id = id&0xFFF;
18816
18817 switch(guysbuf[id].type)
18818 {
18819 case eeTEK:
18820 case eeLEV:
18821 case eeAQUA:
18822 case eeDONGO:
18823 case eeMANHAN:
18824 case eeGLEEOK:
18825 case eeDIG:
18826 case eeGHOMA:
18827 case eeLANM:
18828 case eePATRA:
18829 case eeGANON:
18830 case eePROJECTILE:
18831 return false;
18832 break;
18833 }
18834
18835 return true;
18836 }
18837
18838 bool enemy_spawning_has_checked_been_here;
18839 static bool enemy_spawning_has_been_here;
18840
18841 35048 static bool check_if_recently_visited()
18842 {
18843
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 34526 times.
35048 if (enemy_spawning_has_checked_been_here)
18844 522 return enemy_spawning_has_been_here;
18845
18846 34526 int mi = mapind(cur_map, cur_screen);
18847
18848 34526 enemy_spawning_has_been_here = false;
18849
2/2
✓ Branch 0 taken 207156 times.
✓ Branch 1 taken 34526 times.
241682 for (int i = 0; i < 6; i++)
18850
2/2
✓ Branch 0 taken 197577 times.
✓ Branch 1 taken 9579 times.
216735 if (visited[i] == mi)
18851 9579 enemy_spawning_has_been_here = true;
18852
18853
2/2
✓ Branch 0 taken 9579 times.
✓ Branch 1 taken 24947 times.
34526 if (!enemy_spawning_has_been_here)
18854 {
18855 24947 visited[vhead] = mi; //If not, it adds it to the array,
18856 24947 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
18857 24947 }
18858
18859 34526 enemy_spawning_has_checked_been_here = true;
18860 34526 return enemy_spawning_has_been_here;
18861 35048 }
18862
18863 static std::array<bool, MAPSCRS> script_sle;
18864
18865 static int32_t sle_pattern = 0;
18866 static void script_side_load_enemies(mapscr* scr)
18867 {
18868 if (script_sle[scr->screen] || sle_clk) return;
18869
18870 sle_cnt = 0;
18871 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18872 ++sle_cnt;
18873 script_sle[scr->screen] = true;
18874 sle_pattern = scr->pattern;
18875 sle_clk = 0;
18876 }
18877
18878 54516 static void side_load_enemies(mapscr* scr)
18879 {
18880 54516 int screen = scr->screen;
18881
18882
3/4
✓ Branch 0 taken 683 times.
✓ Branch 1 taken 53833 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 683 times.
54516 if (sle_clk==0 && !script_sle[scr->screen])
18883 {
18884 683 sle_pattern = scr->pattern;
18885 683 sle_cnt = 0;
18886 683 int32_t guycnt = 0;
18887
18888 683 int mi = mapind(cur_map, screen);
18889 683 bool reload=true;
18890 683 bool unbeatablereload = true;
18891
18892 683 load_default_enemies(scr);
18893
18894 683 bool beenhere = check_if_recently_visited();
18895
4/4
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 42 times.
683 if (beenhere && game->guys[mi] == 0)
18896 {
18897 42 sle_cnt=0;
18898 42 reload=false;
18899 42 }
18900
18901
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 641 times.
683 if(reload)
18902 {
18903 641 sle_cnt = game->guys[mi];
18904
18905
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 641 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 221 times.
641 if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
18906 641 || sle_cnt==0)
18907 {
18908
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1272 times.
✓ Branch 2 taken 1054 times.
✓ Branch 3 taken 221 times.
1275 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18909 1054 ++sle_cnt;
18910 221 }
18911
3/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 161 times.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
641 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
18912 {
18913 for(int32_t i = 0; i<sle_cnt && scr->enemy[i]>0; i++)
18914 {
18915 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
18916 {
18917 unbeatablereload = false;
18918 }
18919 }
18920 if (unbeatablereload)
18921 {
18922 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18923 {
18924 ++sle_cnt;
18925 }
18926 }
18927 }
18928 641 }
18929
18930
3/4
✓ Branch 0 taken 652 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 652 times.
683 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN))
18931 {
18932 31 sle_cnt = 0;
18933
18934
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 31 times.
139 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18935 108 ++sle_cnt;
18936 31 }
18937
1/2
✓ Branch 0 taken 683 times.
✗ Branch 1 not taken.
683 if(getmapflag(scr, mNO_ENEMIES_RETURN))
18938 sle_cnt = 0;
18939
18940
2/2
✓ Branch 0 taken 2446 times.
✓ Branch 1 taken 683 times.
3129 for(int32_t i=0; i<sle_cnt; i++)
18941 2446 ++guycnt;
18942
18943 683 game->guys[mi] = guycnt;
18944 683 }
18945
18946
2/2
✓ Branch 0 taken 52087 times.
✓ Branch 1 taken 2429 times.
54516 if((++sle_clk+8)%24 == 0)
18947 {
18948 2429 int32_t dir = next_side_pos(screen, sle_pattern==pSIDESR);
18949 6819 auto [x, y] = translate_screen_coordinates_to_world(screen, sle_x, sle_y);
18950
18951
6/6
✓ Branch 0 taken 2428 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 233 times.
✓ Branch 3 taken 2195 times.
✓ Branch 4 taken 233 times.
✓ Branch 5 taken 2195 times.
2429 if(dir==-1 || tooclose(x,y,32))
18952 {
18953 234 return;
18954 }
18955
18956 2195 int32_t enemy_slot=guys.Count();
18957
18958
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2195 times.
2195 while(sle_cnt > 0 && !ok2add(scr, scr->enemy[sle_cnt-1]))
18959 sle_cnt--;
18960
18961
1/2
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
2195 if(sle_cnt > 0)
18962 {
18963
3/6
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2195 times.
✗ Branch 5 not taken.
6585 if(addenemy(screen, x,y,scr->enemy[--sle_cnt],0))
18964 {
18965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
2195 if (((enemy*)guys.spr(enemy_slot))->type != eeTEK)
18966 {
18967 2195 guys.spr(enemy_slot)->dir = dir;
18968 2195 }
18969
1/2
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
2195 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
18970 {
18971 if (!FFCore.system_suspend[susptNPCSCRIPTS])
18972 {
18973 guys.spr(enemy_slot)->run_script(MODE_NORMAL);
18974 ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true;
18975 }
18976 }
18977 2195 }
18978 2195 }
18979 2195 }
18980
18981
2/2
✓ Branch 0 taken 53704 times.
✓ Branch 1 taken 578 times.
54282 if(sle_cnt<=0)
18982 {
18983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 578 times.
578 if (script_sle[screen])
18984 script_sle[screen] = false;
18985 else
18986 {
18987 578 get_screen_state(screen).loaded_enemies = true;
18988 }
18989 578 sle_clk = 0;
18990 578 }
18991 54516 }
18992
18993 1253524 bool is_starting_pos(mapscr* scr, int32_t i, int32_t x, int32_t y, int32_t t)
18994 {
18995
2/2
✓ Branch 0 taken 116388 times.
✓ Branch 1 taken 1137136 times.
1253524 if (!is_in_scrolling_region())
18996
2/4
✓ Branch 0 taken 1137136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1137136 times.
1137136 if(scr->enemy[i]<1||scr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
18997 {
18998 return false; //never 0, never OoB.
18999 }
19000 // No corner enemies
19001
6/6
✓ Branch 0 taken 1082517 times.
✓ Branch 1 taken 171007 times.
✓ Branch 2 taken 41285 times.
✓ Branch 3 taken 1123802 times.
✓ Branch 4 taken 117940 times.
✓ Branch 5 taken 94352 times.
1253524 if ((x==0 || x==world_w-16) && (y==0 || y==world_h-16))
19002 212292 return false;
19003
19004 //Is a no spawn combo...
19005
4/4
✓ Branch 0 taken 1123788 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 1123794 times.
1123802 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
19006 20 return false;
19007
19008 // No enemies in dungeon walls
19009
2/2
✓ Branch 0 taken 468705 times.
✓ Branch 1 taken 655089 times.
1123794 if (isdungeon(scr->screen))
19010 {
19011 655089 auto [offx, offy] = translate_screen_coordinates_to_world(scr->screen);
19012
17/18
✓ Branch 0 taken 655089 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 582529 times.
✓ Branch 3 taken 72560 times.
✓ Branch 4 taken 582529 times.
✓ Branch 5 taken 72560 times.
✓ Branch 6 taken 509969 times.
✓ Branch 7 taken 72560 times.
✓ Branch 8 taken 509969 times.
✓ Branch 9 taken 72560 times.
✓ Branch 10 taken 422897 times.
✓ Branch 11 taken 87072 times.
✓ Branch 12 taken 422897 times.
✓ Branch 13 taken 87072 times.
✓ Branch 14 taken 87072 times.
✓ Branch 15 taken 335825 times.
✓ Branch 16 taken 87072 times.
✓ Branch 17 taken 335825 times.
655089 if(isdungeon(scr->screen) && (x<32+offx || x>=224+offx || y<32+offy || y>=144+offy))
19013 319264 return false;
19014 335825 }
19015
19016 // Too close to hero
19017
4/4
✓ Branch 0 taken 77038 times.
✓ Branch 1 taken 727492 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 76937 times.
804530 if(tooclose(x,y,40) && t<11)
19018 76937 return false;
19019
19020 // Can't fly onto it?
19021
4/4
✓ Branch 0 taken 139611 times.
✓ Branch 1 taken 587982 times.
✓ Branch 2 taken 35960 times.
✓ Branch 3 taken 25255 times.
788808 if(isflier(scr->enemy[i])&&
19022
2/2
✓ Branch 0 taken 139221 times.
✓ Branch 1 taken 390 times.
139611 (flyerblocked(x+8,y+8,spw_floater,guysbuf[scr->enemy[i]])||
19023
2/2
✓ Branch 0 taken 61215 times.
✓ Branch 1 taken 78006 times.
139221 (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS))))
19024 25645 return false;
19025
19026 // Can't jump onto it?
19027 if
19028 (
19029
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 88704 times.
790656 guysbuf[scr->enemy[i]].type==eeTEK
19030
19031
2/2
✓ Branch 0 taken 88722 times.
✓ Branch 1 taken 613226 times.
701948 &&
19032 (
19033
2/2
✓ Branch 0 taken 88715 times.
✓ Branch 1 taken 7 times.
88722 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
19034
2/2
✓ Branch 0 taken 88714 times.
✓ Branch 1 taken 1 times.
88715 COMBOTYPE(x+8,y+8)==cNOENEMY||
19035
1/2
✓ Branch 0 taken 88714 times.
✗ Branch 1 not taken.
88714 ispitfall(x+8,y+8)||
19036
2/2
✓ Branch 0 taken 88708 times.
✓ Branch 1 taken 6 times.
88714 MAPFLAG(x+8,y+8)==mfNOENEMY||
19037 88708 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
19038 )
19039 )
19040 {
19041 18 return false;
19042 }
19043
19044 // Other off-limit combos
19045
6/6
✓ Branch 0 taken 587958 times.
✓ Branch 1 taken 113972 times.
✓ Branch 2 taken 499254 times.
✓ Branch 3 taken 88704 times.
✓ Branch 4 taken 276494 times.
✓ Branch 5 taken 222760 times.
1201184 if((!isflier(scr->enemy[i])&& guysbuf[scr->enemy[i]].type!=eeTEK &&
19046
2/2
✓ Branch 0 taken 282052 times.
✓ Branch 1 taken 217202 times.
499254 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[scr->enemy[i]]))) &&
19047 499254 guysbuf[scr->enemy[i]].type!=eeZORA)
19048 222760 return false;
19049
19050 // Don't ever generate enemies on these combos!
19051
4/4
✓ Branch 0 taken 478864 times.
✓ Branch 1 taken 306 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 478870 times.
479170 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
19052 312 return false;
19053
19054 //BS Dodongos need at least 2 spaces.
19055
4/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 477831 times.
✓ Branch 2 taken 1014 times.
✓ Branch 3 taken 25 times.
478870 if ((guysbuf[scr->enemy[i]].type==eeDONGO)&&(guysbuf[scr->enemy[i]].attributes[9] == 1))
19056 {
19057
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
25 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
19058
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 ((x>224)||_walkflag(x+16,y+8, 2))&&
19059
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6 ((y<16) ||_walkflag(x, y-8, 2))&&
19060 ((y>144)||_walkflag(x, y+24,2)))
19061 {
19062 return false;
19063 }
19064 19 }
19065
19066 478864 return true;
19067 1147384 }
19068
19069 160640 bool is_ceiling_pattern(int32_t i)
19070 {
19071
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 160620 times.
160640 return (i==pCEILING || i==pCEILINGR);
19072 }
19073
19074 5955 rpos_t placeenemy(mapscr* scr, int32_t i, int32_t offx, int32_t offy)
19075 {
19076 5955 std::vector<rpos_t> freeposcache;
19077
19078
2/2
✓ Branch 0 taken 65505 times.
✓ Branch 1 taken 5955 times.
71460 for(int32_t y=offy; y<offy+176; y+=16)
19079 {
19080
2/2
✓ Branch 0 taken 1048080 times.
✓ Branch 1 taken 65505 times.
1113585 for(int32_t x=offx; x<offx+256; x+=16)
19081 {
19082
3/4
✓ Branch 0 taken 1048080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 421055 times.
✓ Branch 3 taken 627025 times.
1048080 if(is_starting_pos(scr,i,x,y,0))
19083 {
19084
2/4
✓ Branch 0 taken 421055 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 421055 times.
✗ Branch 3 not taken.
421055 freeposcache.push_back(COMBOPOS_REGION(x, y));
19085 421055 }
19086 1048080 }
19087 65505 }
19088
19089
2/2
✓ Branch 0 taken 5944 times.
✓ Branch 1 taken 11 times.
5955 if (!freeposcache.empty())
19090
1/2
✓ Branch 0 taken 5944 times.
✗ Branch 1 not taken.
5944 return freeposcache[zc_oldrand()%freeposcache.size()];
19091
19092 11 return rpos_t::None;
19093 5955 }
19094
19095 81131 void spawnEnemy(mapscr* scr, int& pos, int& clk, int offx, int offy, int& fastguys, int& i, int& guycnt, int& loadcnt)
19096 {
19097 81131 int screen = scr->screen;
19098 81131 int x = 0;
19099 81131 int y = 0;
19100 81131 bool placed=false;
19101 81131 int32_t t=-1;
19102
19103 // First: enemy combo flags
19104
2/2
✓ Branch 0 taken 805424 times.
✓ Branch 1 taken 63764 times.
869188 for(int32_t sy=0; sy<176; sy+=16)
19105 {
19106
2/2
✓ Branch 0 taken 12757620 times.
✓ Branch 1 taken 788057 times.
13545677 for(int32_t sx=0; sx<256; sx+=16)
19107 {
19108 12757620 x = offx + sx;
19109 12757620 y = offy + sy;
19110 12757620 int32_t cflag = MAPFLAG(x, y);
19111 12757620 int32_t cflag_i = MAPCOMBOFLAG(x, y);
19112
19113
2/4
✓ Branch 0 taken 12757620 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12757620 times.
✗ Branch 3 not taken.
12757620 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
19114 {
19115 if(!ok2add(scr, scr->enemy[i]))
19116 {
19117 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19118 }
19119 else
19120 {
19121 addenemy_z(screen,x,
19122 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19123 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19124
19125 ++guycnt;
19126
19127 placed=true;
19128 goto placed_enemy;
19129 }
19130 }
19131
19132
4/4
✓ Branch 0 taken 12740204 times.
✓ Branch 1 taken 17416 times.
✓ Branch 2 taken 12740204 times.
✓ Branch 3 taken 17416 times.
12757620 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
19133 {
19134
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 17367 times.
17416 if(!ok2add(scr, scr->enemy[i]))
19135 {
19136
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
49 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19137 49 }
19138 else
19139 {
19140 34734 addenemy_z(screen,x,
19141
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17366 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
17367 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19142
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17366 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
17367 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19143
19144 17367 ++guycnt;
19145
19146 17367 placed=true;
19147 17367 goto placed_enemy;
19148 }
19149 49 }
19150 12740253 }
19151 788057 }
19152
19153 // Next: enemy pattern
19154
6/8
✓ Branch 0 taken 4997 times.
✓ Branch 1 taken 58767 times.
✓ Branch 2 taken 58030 times.
✓ Branch 3 taken 5734 times.
✓ Branch 4 taken 58030 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 58030 times.
63764 if((scr->pattern==pRANDOM || scr->pattern==pCEILING) && !(isSideViewGravity()) && ((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS)))
19155 {
19156 58030 do
19157 {
19158
19159 // NES positions
19160 99525 pos%=9;
19161 99525 x=offx+stx[loadside][pos];
19162 99525 y=offy+sty[loadside][pos];
19163 99525 ++pos;
19164 99525 ++t;
19165
2/2
✓ Branch 0 taken 41495 times.
✓ Branch 1 taken 58030 times.
157555 }
19166
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 99304 times.
99525 while((t< 20) && !is_starting_pos(scr,i,x,y,t));
19167 58030 }
19168
19169
4/4
✓ Branch 0 taken 58030 times.
✓ Branch 1 taken 5734 times.
✓ Branch 2 taken 221 times.
✓ Branch 3 taken 57809 times.
63764 if(t<0 || t >= 20) // above enemy pattern failed
19170 {
19171 // Final chance: find a random position anywhere onscreen
19172 5955 rpos_t rand_rpos = placeenemy(scr, i, offx, offy);
19173
19174
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5944 times.
5955 if (rand_rpos != rpos_t::None)
19175 {
19176 5944 std::tie(x, y) = COMBOXY_REGION(rand_rpos);
19177 5944 }
19178 else // All opportunities failed - abort
19179 {
19180 11 return;
19181 }
19182 5944 }
19183
19184 {
19185 63753 int32_t c=0;
19186 63753 c=clk;
19187
19188
2/2
✓ Branch 0 taken 9643 times.
✓ Branch 1 taken 54110 times.
63753 if(!slowguy(scr->enemy[i]))
19189 54110 ++fastguys;
19190
2/2
✓ Branch 0 taken 1586 times.
✓ Branch 1 taken 8057 times.
9643 else if(fastguys>0)
19191 1586 c=-15*(i-fastguys+2);
19192 else
19193 8057 c=-15*(i+1);
19194
19195
4/6
✓ Branch 0 taken 29160 times.
✓ Branch 1 taken 34593 times.
✓ Branch 2 taken 29160 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29160 times.
63753 if(BSZ&&((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19196 {
19197 // Special case for blue leevers
19198
4/4
✓ Branch 0 taken 1894 times.
✓ Branch 1 taken 27266 times.
✓ Branch 2 taken 761 times.
✓ Branch 3 taken 1133 times.
29160 if(guysbuf[scr->enemy[i]].type==eeLEV && guysbuf[scr->enemy[i]].attributes[0] == 1)
19199 761 c=-15*(i+1);
19200 else
19201 28399 c=-15;
19202 29160 }
19203
19204
2/2
✓ Branch 0 taken 62953 times.
✓ Branch 1 taken 800 times.
63753 if(!ok2add(scr, scr->enemy[i]))
19205 {
19206
4/6
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 670 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 130 times.
800 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19207 800 }
19208 else
19209 {
19210
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62953 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62953 if(((scr->enemy[i]>0||scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19211 {
19212
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 62777 times.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
125906 addenemy_z(screen,x,(is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19213
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 62777 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 176 times.
62953 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],c);
19214
19215 62953 ++guycnt;
19216 62953 }
19217 }
19218
19219 63753 placed=true;
19220 63753 } // if(t < 20)
19221
19222 placed_enemy:
19223
19224 // I don't like this, but it seems to work...
19225 static bool foundCarrier;
19226
19227
2/2
✓ Branch 0 taken 59508 times.
✓ Branch 1 taken 21612 times.
81120 if(i==0)
19228 21612 foundCarrier=false;
19229
19230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81120 times.
81120 if(placed)
19231 {
19232
4/4
✓ Branch 0 taken 21612 times.
✓ Branch 1 taken 59508 times.
✓ Branch 2 taken 21443 times.
✓ Branch 3 taken 169 times.
81120 if(i==0 && scr->flags11&efLEADER)
19233 {
19234 169 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19235
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 7 times.
169 if (e)
19236 {
19237 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
19238
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 if ((e->type == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER))
19239 {
19240 e = find_guy_nth_for_id(screen, scr->enemy[i], 2, 0xFFF);
19241 }
19242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
162 if (e)
19243 {
19244 162 e->leader = true;
19245 162 }
19246 162 }
19247 169 }
19248
19249 81120 ScreenItemState item_state = get_screen_state(screen).item_state;
19250
5/6
✓ Branch 0 taken 80878 times.
✓ Branch 1 taken 242 times.
✓ Branch 2 taken 80878 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✓ Branch 5 taken 80801 times.
81120 if (!foundCarrier && (item_state == ScreenItemState::CarriedByEnemy || item_state == ScreenItemState::MustGiveToEnemy))
19251 {
19252 77 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19253
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 if (e && (e->flags&guy_doesnt_count)==0)
19254 {
19255 77 e->itemguy = true;
19256 77 foundCarrier=true;
19257 77 }
19258 77 }
19259 81120 }
19260 81131 }
19261
19262 // returns index of first sprite with matching id, -1 if none found
19263 246 enemy* find_guy_first_for_id(int screen, int id, int mask)
19264 {
19265 246 int count = guys.Count();
19266
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 7 times.
373 for (int32_t i=0; i<count; i++)
19267 {
19268 366 enemy* e = (enemy*)guys.spr(i);
19269
4/4
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 239 times.
✓ Branch 3 taken 79 times.
366 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19270 {
19271 239 return e;
19272 }
19273 127 }
19274
19275 7 return nullptr;
19276 246 }
19277
19278 enemy* find_guy_nth_for_id(int screen, int id, int n, int mask)
19279 {
19280 int count = guys.Count();
19281 for(int32_t i=0; i<count; i++)
19282 {
19283 enemy* e = (enemy*)guys.spr(i);
19284 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19285 {
19286 if (n > 1) --n;
19287 else return e;
19288 }
19289 }
19290 return nullptr;
19291 }
19292
19293 bool scriptloadenemies(int screen)
19294 {
19295 auto& state = get_screen_state(screen);
19296 state.loaded_enemies = true;
19297
19298 if (sle_clk || script_sle[screen]) return false;
19299
19300 mapscr* scr = get_scr(screen);
19301 if(scr->pattern==pNOSPAWN) return false;
19302
19303 if(scr->pattern==pSIDES || scr->pattern==pSIDESR)
19304 {
19305 script_side_load_enemies(scr);
19306 return true;
19307 }
19308
19309 auto [x, y] = translate_screen_coordinates_to_world(screen);
19310 int32_t pos=zc_oldrand()%9;
19311 int32_t clk=-15,fastguys=0;
19312 int32_t i=0,guycnt=0;
19313 int32_t loadcnt = 10;
19314
19315 for(; i<loadcnt && scr->enemy[i]>0; i++)
19316 {
19317 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19318 spawnEnemy(scr, pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19319 if (guys.Count() > preguycount)
19320 {
19321 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19322 {
19323 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19324 {
19325 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19326 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19327 }
19328 }
19329 }
19330 --clk;
19331 }
19332 return true;
19333 }
19334
19335 14267721 void loadenemies()
19336 {
19337 28915600 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
19338 14647879 int screen = scr->screen;
19339 14647879 auto& state = get_screen_state(screen);
19340
2/2
✓ Branch 0 taken 14232652 times.
✓ Branch 1 taken 415227 times.
14647879 if (state.loaded_enemies)
19341 14232652 return;
19342
19343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 415227 times.
415227 if(getmapflag(scr, mNO_ENEMIES_RETURN))
19344 return;
19345
19346 // dungeon basements
19347 static byte dngn_enemy_x[4] = {32,96,144,208};
19348
2/2
✓ Branch 0 taken 148964 times.
✓ Branch 1 taken 266263 times.
415227 if (cur_screen>=128)
19349 {
19350
2/2
✓ Branch 0 taken 148489 times.
✓ Branch 1 taken 475 times.
148964 if(DMaps[cur_dmap].flags&dmfCAVES) return;
19351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if ( DMaps[cur_dmap].flags&dmfNEWCELLARENEMIES )
19352 {
19353 for(int32_t i=0; i<10; i++)
19354 {
19355 if ( scr->enemy[i] )
19356 {
19357 int32_t preguycount = guys.Count();
19358 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i],-14-i);
19359 if (guys.Count() > preguycount)
19360 {
19361 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19362 {
19363 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19364 {
19365 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19366 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19367 }
19368 }
19369 }
19370 }
19371 }
19372 }
19373 else
19374 {
19375
2/2
✓ Branch 0 taken 1900 times.
✓ Branch 1 taken 475 times.
2375 for(int32_t i=0; i<4; i++)
19376 {
19377 1900 int32_t preguycount = guys.Count();
19378
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 856 times.
1900 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i]?scr->enemy[i]:(int32_t)eKEESE1,-14-i);
19379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1900 times.
1900 if (guys.Count() > preguycount)
19380 {
19381
2/2
✓ Branch 0 taken 1896 times.
✓ Branch 1 taken 4 times.
1900 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19382 {
19383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19384 {
19385 4 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19386 4 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19387 4 }
19388 4 }
19389 1900 }
19390 1900 }
19391 }
19392
19393 475 state.loaded_enemies = true;
19394 475 return;
19395 }
19396
19397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 266263 times.
266263 if (scr->pattern == pNOSPAWN)
19398 return;
19399
19400 // TODO: configure when screen enemies spawn.
19401
2/2
✓ Branch 0 taken 88971 times.
✓ Branch 1 taken 177292 times.
266263 if (!viewport.intersects_with(region_scr_x*256, region_scr_y*176, 256, 176))
19402 177292 return;
19403
19404
4/4
✓ Branch 0 taken 50524 times.
✓ Branch 1 taken 38447 times.
✓ Branch 2 taken 16069 times.
✓ Branch 3 taken 34455 times.
88971 if (scr->pattern==pSIDES || scr->pattern==pSIDESR)
19405 {
19406 54516 side_load_enemies(scr);
19407 54516 return;
19408 }
19409
19410 34455 state.loaded_enemies = true;
19411
19412 // check if it's the dungeon boss and it has been beaten before
19413
4/4
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 34096 times.
✓ Branch 2 taken 269 times.
✓ Branch 3 taken 90 times.
34455 if (scr->flags11&efBOSS && game->lvlitems[dlevel]&liBOSS)
19414 90 return;
19415
19416 34365 int32_t loadcnt = 10;
19417 34365 int16_t mi = mapind(cur_map, screen);
19418 34365 bool beenhere = check_if_recently_visited();
19419
19420 //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
19421 34365 bool reload = true;
19422
4/4
✓ Branch 0 taken 9722 times.
✓ Branch 1 taken 24643 times.
✓ Branch 2 taken 4708 times.
✓ Branch 3 taken 5014 times.
34365 if (beenhere && game->guys[mi] == 0) //Then, if you have been here, and the number of enemies left on the screen is 0,
19423 {
19424 5014 loadcnt = 0; //It will tell it not to load any enemies,
19425 5014 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
19426 5014 }
19427
19428 34365 bool unbeatablereload = true;
19429
2/2
✓ Branch 0 taken 5014 times.
✓ Branch 1 taken 29351 times.
34365 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
19430 {
19431 29351 loadcnt = game->guys[mi]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
19432
19433
2/4
✓ Branch 0 taken 10289 times.
✓ Branch 1 taken 19062 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29351 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
19434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10289 times.
10289 (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
19435 19062 loadcnt = 10; //That means all enemies need to be respawned.
19436
3/4
✓ Branch 0 taken 24643 times.
✓ Branch 1 taken 4708 times.
✓ Branch 2 taken 24643 times.
✗ Branch 3 not taken.
29351 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19437 {
19438 for(int32_t i = 0; i<loadcnt && scr->enemy[i]>0; i++)
19439 {
19440 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
19441 {
19442 unbeatablereload = false;
19443 }
19444 }
19445 if (unbeatablereload)
19446 {
19447 loadcnt = 10;
19448 }
19449 }
19450 29351 }
19451
19452
4/4
✓ Branch 0 taken 32904 times.
✓ Branch 1 taken 1461 times.
✓ Branch 2 taken 193 times.
✓ Branch 3 taken 32711 times.
34365 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
19453 1654 loadcnt = 10; //All enemies also need to be respawned.
19454
19455 // do enemies that are always loaded
19456 34365 load_default_enemies(scr);
19457 34365 activate_fireball_statues(scr);
19458
19459 34365 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
19460 34365 int32_t clk=-15,fastguys=0; //clk being negative means the enemy is in it's spawn poof.
19461 34365 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
19462
4/4
✓ Branch 0 taken 15156 times.
✓ Branch 1 taken 100340 times.
✓ Branch 2 taken 81131 times.
✓ Branch 3 taken 34365 times.
115496 for(; i<loadcnt && scr->enemy[i]>0; i++)
19463 {
19464 81131 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19465 81131 spawnEnemy(scr, pos, clk, region_scr_x*256, region_scr_y*176, fastguys, i, guycnt, loadcnt);
19466
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 80320 times.
81131 if (guys.Count() > preguycount)
19467 {
19468
2/2
✓ Branch 0 taken 77968 times.
✓ Branch 1 taken 2352 times.
80320 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19469 {
19470
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2348 times.
2352 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19471 {
19472 2348 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19473 2348 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19474 2348 }
19475 2352 }
19476 80320 }
19477
19478 81131 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
19479 81131 }
19480
19481 34365 game->guys[mi] = guycnt;
19482 14647879 });
19483 14267721 }
19484
19485 233 void moneysign()
19486 {
19487 466 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
19488 466 additem(dx+48,dy+108,iRupy,ipDUMMY);
19489 233 set_clip_state(pricesdisplaybuf, 0);
19490 233 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
19491 233 }
19492
19493 3303 void putprices(bool sign)
19494 {
19495
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 3271 times.
3303 if(fadeclk > 0) return;
19496
19497 3271 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
19498 3271 int32_t step=32;
19499 3271 int32_t x=80;
19500
19501
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 2990 times.
3271 if(prices[2]==0)
19502 {
19503 2990 step<<=1;
19504
19505
2/2
✓ Branch 0 taken 2958 times.
✓ Branch 1 taken 32 times.
2990 if(prices[1]==0)
19506 {
19507 2958 x=112;
19508 2958 }
19509 2990 }
19510
19511
2/2
✓ Branch 0 taken 3271 times.
✓ Branch 1 taken 9813 times.
13084 for(int32_t i=0; i<3; i++)
19512 {
19513 // Kind of stupid, but it works: 100000 is used to indicate that an item
19514 // has a price of zero rather than there being no item.
19515 // 100000 isn't a valid price, so this doesn't cause problems.
19516
3/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 8774 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1039 times.
9813 if(prices[i]!=0 && prices[i]<100000)
19517 {
19518 char buf[8];
19519 1039 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
19520
19521 1039 int32_t l=(int32_t)strlen(buf);
19522 1039 set_clip_state(pricesdisplaybuf, 0);
19523
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1012 times.
1039 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
19524 1039 }
19525
19526 9813 x+=step;
19527 9813 }
19528 3303 }
19529
19530 // Setting up special rooms
19531 // Also called when the Letter is used successfully.
19532 1210 void setupscreen()
19533 {
19534 1210 boughtsomething=false;
19535
19536 // Either the origin screen, or if in a 0x80 room the screen player came from.
19537
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 794 times.
1210 mapscr* base_scr = cur_screen >= 128 ? special_warp_return_scr : origin_scr;
19538 1210 mapscr* scr = origin_scr;
19539
19540 1210 word str=base_scr->str;
19541
19542 2262 auto [dx, dy] = translate_screen_coordinates_to_world(scr->screen);
19543
19544 // Prices are already set to 0 in dowarp()
19545
14/15
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 689 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 11 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 17 times.
✓ Branch 10 taken 32 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 19 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 14 times.
1210 switch(base_scr->room)
19546 {
19547 case rSP_ITEM: // special item
19548 328 additem(dx+120,dy+89,base_scr->catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
19549 164 break;
19550
19551 case rINFO: // pay for info
19552 {
19553 28 int32_t count = 0;
19554 28 int32_t base = 88;
19555 28 int32_t step = 5;
19556
19557 28 moneysign();
19558
19559
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 84 times.
112 for(int32_t i=0; i<3; i++)
19560 {
19561
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(QMisc.info[base_scr->catchall].str[i])
19562 {
19563 84 ++count;
19564 84 }
19565 else
19566 break;
19567 84 }
19568
19569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(count)
19570 {
19571
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==1)
19572 {
19573 base = 88+32;
19574 }
19575
19576
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==2)
19577 {
19578 step = 6;
19579 }
19580
19581
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 28 times.
112 for(int32_t i=0; i < count; i++)
19582 {
19583 84 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
19584 84 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19585 84 prices[i] = -(QMisc.info[base_scr->catchall].price[i]);
19586
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(prices[i]==0)
19587 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19588 84 int32_t itemid = current_item_id(itype_wealthmedal);
19589
19590
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if(itemid>=0 && prices[i]!=100000)
19591 {
19592 if(itemsbuf[itemid].flags & item_flag1)
19593 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19594 else
19595 prices[i]-=itemsbuf[itemid].misc1;
19596 prices[i]=vbound(prices[i], -99999, 0);
19597 if(prices[i]==0)
19598 prices[i]=100000;
19599 }
19600
19601
2/6
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if((QMisc.info[base_scr->catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
19602 prices[i]=-1;
19603 84 }
19604 28 }
19605
19606 28 break;
19607 }
19608
19609 case rMONEY: // secret money
19610 88 additem(dx+120,dy+89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
19611 44 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19612 44 break;
19613
19614 case rGAMBLE: // gambling
19615 11 prices[0]=prices[1]=prices[2]=-10;
19616 11 moneysign();
19617 22 additem(dx+88,dy+89,iRupy,ipMONEY+ipDUMMY);
19618 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19619 22 additem(dx+120,dy+89,iRupy,ipMONEY+ipDUMMY);
19620 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19621 22 additem(dx+152,dy+89,iRupy,ipMONEY+ipDUMMY);
19622 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
19623 11 break;
19624
19625 case rREPAIR: // door repair
19626
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
19627 // }
19628 13 repaircharge=base_scr->catchall;
19629 13 break;
19630
19631 case rMUPGRADE: // upgrade magic
19632 2 adjustmagic=true;
19633 2 break;
19634
19635 case rLEARNSLASH: // learn slash attack
19636 2 learnslash=true;
19637 2 break;
19638
19639 case rRP_HC: // heart container or red potion
19640 34 additem(dx+88,dy+89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
19641 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19642 34 additem(dx+152,dy+89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
19643 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19644 17 break;
19645
19646 case rP_SHOP: // potion shop
19647
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 20 times.
32 if(current_item(itype_letter)<i_letter_used)
19648 {
19649 12 str=0;
19650 12 break;
19651 }
19652
19653 [[fallthrough]];
19654 case rTAKEONE: // take one
19655 case rSHOP: // shop
19656 {
19657 194 int32_t count = 0;
19658 194 int32_t base = 88;
19659 194 int32_t step = 5;
19660
19661
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 193 times.
194 if(base_scr->room != rTAKEONE)
19662 193 moneysign();
19663
19664 //count and align the stuff
19665
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 560 times.
717 for(int32_t i=0; i<3; ++i)
19666 {
19667
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 37 times.
560 if(QMisc.shop[base_scr->catchall].hasitem[count] != 0)
19668 {
19669 523 ++count;
19670 523 }
19671 else
19672 {
19673 37 break;
19674 }
19675 523 }
19676
19677
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 22 times.
194 if(count==1)
19678 {
19679 22 base = 88+32;
19680 22 }
19681
19682
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 15 times.
194 if(count==2)
19683 {
19684 15 step = 6;
19685 15 }
19686
19687
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 194 times.
717 for(int32_t i=0; i<count; i++)
19688 {
19689 1046 additem(dx+(i<<step)+base, dy+89, QMisc.shop[base_scr->catchall].item[i], ipHOLDUP+ipFADE+(base_scr->room == rTAKEONE ? ipONETIME2 : ipCHECK));
19690 523 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19691
19692
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 521 times.
523 if(base_scr->room != rTAKEONE)
19693 {
19694 521 prices[i] = QMisc.shop[base_scr->catchall].price[i];
19695
1/2
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
521 if(prices[i]==0)
19696 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19697 521 int32_t itemid = current_item_id(itype_wealthmedal);
19698
19699
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
521 if(itemid>=0 && prices[i]!=100000)
19700 {
19701
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(itemsbuf[itemid].flags & item_flag1)
19702 9 prices[i]=((prices[i]*itemsbuf[itemid].misc1) / 100);
19703 else
19704 prices[i]+=itemsbuf[itemid].misc1;
19705 9 prices[i]=vbound(prices[i], 0, 99999);
19706
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(prices[i]==0)
19707 prices[i]=100000;
19708 9 }
19709
19710
2/4
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 521 times.
✗ Branch 3 not taken.
521 if((QMisc.shop[base_scr->catchall].price[i])>1 && prices[i]<1)
19711 prices[i]=1;
19712 521 }
19713 523 }
19714
19715 194 break;
19716 }
19717 case rBOTTLESHOP: // bottle shop
19718 {
19719 1 int32_t count = 0;
19720 1 int32_t base = 88;
19721 1 int32_t step = 5;
19722
19723 1 moneysign();
19724 1 bottleshoptype const& bst = QMisc.bottle_shop_types[base_scr->catchall];
19725 //count and align the stuff
19726
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
4 for(int32_t i=0; i<3; ++i)
19727 {
19728
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(bst.fill[count] != 0)
19729 {
19730 3 ++count;
19731 3 }
19732 else
19733 {
19734 break;
19735 }
19736 3 }
19737
19738
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==1)
19739 {
19740 base = 88+32;
19741 }
19742
19743
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==2)
19744 {
19745 step = 6;
19746 }
19747
19748
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for(int32_t i=0; i<count; i++)
19749 {
19750 6 adddummyitem(dx+(i<<step)+base, dy+89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
19751 //{ Setup dummy item
19752 3 item* curItem = ((item*)items.spr(items.Count()-1));
19753 3 curItem->PriceIndex = i;
19754 3 newcombo const& cmb = combobuf[bst.comb[i]];
19755
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(cmb.animflags & AF_EDITOR_ONLY)
19756 {
19757 curItem->yofs = -32768;
19758 }
19759 3 curItem->o_tile = cmb.o_tile;
19760 3 curItem->o_cset = bst.cset[i];
19761 3 curItem->cs = curItem->o_cset;
19762 3 curItem->tile = cmb.o_tile;
19763 3 curItem->o_speed = cmb.speed;
19764 3 curItem->o_delay = 0;
19765 3 curItem->frames = cmb.frames;
19766 3 curItem->flip = cmb.flip;
19767 3 curItem->type = itype_bottlefill; //no pickup w/o empty bottle
19768 3 curItem->pstring = 0;
19769 3 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
19770 3 curItem->flash = false;
19771 3 curItem->twohand = false;
19772 3 curItem->anim = true;
19773 3 curItem->hit_width=1;
19774 3 curItem->hyofs=4;
19775 3 curItem->hit_height=12;
19776 3 curItem->script=0;
19777 3 curItem->txsz=1;
19778 3 curItem->tysz=1;
19779 //}
19780
19781 3 prices[i] = bst.price[i];
19782
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(prices[i]==0)
19783 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19784 3 int32_t itemid = current_item_id(itype_wealthmedal);
19785
19786
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(itemid>=0 && prices[i]!=100000)
19787 {
19788 if(itemsbuf[itemid].flags & item_flag1)
19789 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19790 else
19791 prices[i]+=itemsbuf[itemid].misc1;
19792 prices[i]=vbound(prices[i], 0, 99999);
19793 if(prices[i]==0)
19794 prices[i]=100000;
19795 }
19796
19797
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if((bst.price[i])>1 && prices[i]<1)
19798 prices[i]=1;
19799 3 }
19800
19801 1 break;
19802 }
19803
19804 case rBOMBS: // more bombs
19805 38 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19806 19 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19807 19 prices[0]=-base_scr->catchall;
19808 19 break;
19809
19810 case rARROWS: // more arrows
19811 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19812 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19813 prices[0]=-base_scr->catchall;
19814 break;
19815
19816 case rSWINDLE: // leave heart container or money
19817 28 additem(dx+88,dy+89,iHeartC,ipDUMMY+ipMONEY);
19818 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19819 14 prices[0]=-1;
19820 28 additem(dx+152,dy+89,iRupy,ipDUMMY+ipMONEY);
19821 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19822 14 prices[1]=-base_scr->catchall;
19823 14 break;
19824
19825 }
19826
19827
3/4
✓ Branch 0 taken 1191 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1191 times.
1210 if(base_scr->room == rBOMBS || base_scr->room == rARROWS)
19828 {
19829 19 int32_t i = (base_scr->room == rSWINDLE ? 1 : 0);
19830 19 int32_t itemid = current_item_id(itype_wealthmedal);
19831
19832
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(itemid >= 0)
19833 {
19834 if(itemsbuf[itemid].flags & item_flag1)
19835 prices[i]*=(itemsbuf[itemid].misc1 /100.0);
19836 else
19837 prices[i]+=itemsbuf[itemid].misc1;
19838 }
19839
19840
2/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
19 if(base_scr->catchall>1 && prices[i]>-1)
19841 prices[i]=-1;
19842 19 }
19843
19844 1210 putprices(false);
19845
19846
2/2
✓ Branch 0 taken 1151 times.
✓ Branch 1 taken 59 times.
1210 if(str)
19847 {
19848 1151 donewmsg(base_scr, str);
19849 1151 }
19850 else
19851 {
19852 59 Hero.unfreeze();
19853 }
19854 1210 }
19855
19856 enum
19857 {
19858 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
19859 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
19860
19861 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
19862
19863 MNU_DATA_MAX
19864 };
19865 struct menu_choice
19866 {
19867 int32_t x, y;
19868 int32_t pos;
19869 int32_t upos, dpos, lpos, rpos;
19870 18 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
19871 18 {}
19872 18 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
19873 int32_t dpos, int32_t lpos, int32_t rpos)
19874 18 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
19875 18 {}
19876 };
19877 static int32_t msg_menu_data[MNU_DATA_MAX];
19878 static bool do_run_menu = false;
19879 bool do_end_str = false;
19880 static bool wait_advance = false;
19881 412 static std::map<int32_t, menu_choice> menu_options;
19882 43871 void clr_msg_data()
19883 {
19884 43871 do_end_str = false;
19885 43871 wait_advance = false;
19886 43871 do_run_menu = false;
19887 43871 menu_options.clear();
19888 43871 memset(msg_menu_data, 0, sizeof(msg_menu_data));
19889 43871 }
19890
19891 static char namebuf[9] = {0};
19892 static char* nameptr = NULL;
19893 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
19894 2036 bool runMenuCursor()
19895 {
19896 2036 clear_bitmap(msg_menu_bmp_buf);
19897
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(!menu_options.size())
19898 {
19899 msg_menu_data[MNU_CHOSEN] = 0;
19900 return true; //end menu
19901 }
19902 2036 int32_t pos = msg_menu_data[MNU_CHOSEN];
19903 //If the cursor is at an invalid pos, find the first pos >= 0...
19904
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(menu_options.find(pos) == menu_options.end())
19905 {
19906 pos = 0;
19907 while(menu_options.find(pos) == menu_options.end())
19908 ++pos;
19909 }
19910 2036 menu_choice* ch = &menu_options[pos];
19911
19912 2036 bool pressed = true;
19913
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2032 times.
2036 if(rUp()) pos = ch->upos;
19914
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2030 times.
2032 else if(rDown()) pos = ch->dpos;
19915
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2021 times.
2030 else if(rLeft()) pos = ch->lpos;
19916
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2010 times.
2021 else if(rRight()) pos = ch->rpos;
19917 2010 else pressed = false;
19918
19919
2/2
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
2036 if(pressed)
19920 26 msg_menu_data[MNU_TIMER] = 1;
19921
19922 2036 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 20);
19923 2036 bool held = false;
19924
2/2
✓ Branch 0 taken 1946 times.
✓ Branch 1 taken 90 times.
2036 if(hold_input)
19925 {
19926 90 held = true;
19927
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 89 times.
90 if(Up()) pos = ch->upos;
19928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Down()) pos = ch->dpos;
19929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Left()) pos = ch->lpos;
19930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Right()) pos = ch->rpos;
19931 89 else held = false;
19932 90 }
19933 //If the cursor is at an invalid pos, find the first pos >= 0...
19934
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(menu_options.find(pos) == menu_options.end())
19935 {
19936 pos = 0;
19937 while(menu_options.find(pos) == menu_options.end())
19938 ++pos;
19939 }
19940
4/4
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2009 times.
✓ Branch 3 taken 27 times.
2036 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
19941 27 sfx(MsgStrings[msgstr].sfx);
19942
19943 2036 ch = &menu_options[pos];
19944 4072 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
19945 2036 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
19946 2036 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
19947 2036 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
19948
19949 2036 msg_menu_data[MNU_CHOSEN] = pos;
19950
19951
2/2
✓ Branch 0 taken 1433 times.
✓ Branch 1 taken 603 times.
2036 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
19952 {
19953 603 rAbtn(); //Eat
19954
2/2
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 5 times.
603 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
19955 603 }
19956
19957
4/4
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2009 times.
2036 bool ret = (pressed || held) ? false : rAbtn();
19958 //Eat inputs
19959 2036 rUp(); rDown(); rLeft(); rRight(); rAbtn();
19960
19961
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 5 times.
2036 if(ret)
19962 5 menu_options.clear();
19963
19964 2036 return ret;
19965 //false if pos changed this frame; no confirming while moving the cursor!
19966 2036 }
19967
19968 839994 bool bottom_margin_clip()
19969 {
19970 891831 return !get_qr(qr_OLD_STRING_EDITOR_MARGINS)
19971
2/2
✓ Branch 0 taken 788157 times.
✓ Branch 1 taken 51837 times.
839994 && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
19972 }
19973
19974 void update_msgstr();
19975
19976 3293 static bool parsemsgcode(const StringCommand& command)
19977 {
19978 3293 auto& args = command.args;
19979 3293 int last_arg = 0;
19980
19981
18/38
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1280 times.
✓ Branch 3 taken 1644 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 56 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 70 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 11 times.
✓ Branch 14 taken 22 times.
✓ Branch 15 taken 7 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 122 times.
✓ Branch 24 taken 28 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 5 times.
✓ Branch 29 taken 18 times.
✓ Branch 30 taken 5 times.
✓ Branch 31 taken 7 times.
✓ Branch 32 taken 3 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
3293 switch (command.code)
19982 {
19983 case MSGC_NEWLINE:
19984 {
19985 1280 ssc_tile_hei = ssc_tile_hei_buf;
19986
2/2
✓ Branch 0 taken 1278 times.
✓ Branch 1 taken 2 times.
1280 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
19987 1280 ssc_tile_hei_buf = -1;
19988 1280 cursor_y += thei + MsgStrings[msgstr].vspace;
19989 1280 cursor_x=msg_margins[left];
19990 1280 return true;
19991 }
19992
19993 case MSGC_COLOUR:
19994 {
19995 1644 int32_t cset = args[0];
19996 1644 msgcolour = CSET(cset)+(args[1]);
19997 1644 return true;
19998 }
19999
20000 case MSGC_SHDCOLOR:
20001 {
20002 int32_t cset = args[0];
20003 msg_shdcol = CSET(cset)+args[1];
20004 return true;
20005 }
20006 case MSGC_SHDTYPE:
20007 {
20008 msg_shdtype = args[0];
20009 return true;
20010 }
20011
20012 case MSGC_SPEED:
20013 {
20014 56 msgspeed=args[0];
20015 56 return true;
20016 }
20017
20018 case MSGC_CTRUP:
20019 {
20020 int32_t a1 = args[0];
20021 int32_t a2 = args[1];
20022 game->change_counter(a2, a1);
20023 return true;
20024 }
20025
20026 case MSGC_CTRDN:
20027 {
20028 5 int32_t a1 = args[0];
20029 5 int32_t a2 = args[1];
20030 5 game->change_counter(-a2, a1);
20031 5 return true;
20032 }
20033
20034 case MSGC_CTRSET:
20035 {
20036 7 int32_t a1 = args[0];
20037 7 int32_t a2 = args[1];
20038 7 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
20039 7 return true;
20040 }
20041
20042 case MSGC_CTRUPPC:
20043 case MSGC_CTRDNPC:
20044 case MSGC_CTRSETPC:
20045 {
20046 2 int32_t counter = args[0];
20047 2 int32_t amount = args[1];
20048 2 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
20049
20050
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(command.code==MSGC_CTRDNPC)
20051 amount*=-1;
20052
20053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(command.code==MSGC_CTRSETPC)
20054 game->set_counter(amount, counter);
20055 else
20056 2 game->change_counter(amount, counter);
20057
20058 2 return true;
20059 }
20060
20061 case MSGC_GIVEITEM:
20062 {
20063 70 int32_t itemID = args[0];
20064
20065 70 getitem(itemID, true);
20066
2/4
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
70 if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) )
20067 {
20068 70 FFCore.reset_script_engine_data(ScriptType::Item, itemID);
20069 70 FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&item_passive_script) > 0;
20070 70 }
20071 70 return true;
20072 }
20073
20074
20075 case MSGC_WARP:
20076 {
20077 int32_t dmap = args[0];
20078 int32_t scrn = args[1];
20079 int32_t dx = args[2];
20080 int32_t dy = args[3];
20081 int32_t wfx = args[4];
20082 int32_t sfx = args[5];
20083 if(dx >= MAX_SCC_ARG) dx = -1;
20084 if(dy >= MAX_SCC_ARG) dy = -1;
20085 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, 0, 0);
20086 do_end_str = true;
20087 return true;
20088 }
20089
20090 case MSGC_SETSCREEND:
20091 {
20092 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20093 int32_t screen = args[1];
20094 int32_t reg = args[2];
20095 int32_t val = args[3];
20096 FFCore.set_screen_d(screen + dmap, reg, val);
20097 return true;
20098 }
20099 case MSGC_TAKEITEM:
20100 {
20101 11 int32_t itemID = args[0];
20102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if ( FFCore.doscript(ScriptType::Item, itemID) )
20103 {
20104 FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit'
20105 }
20106 11 takeitem(itemID);
20107
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_bwpn == itemID )
20108 {
20109 game->forced_bwpn = -1;
20110 } //not else if! -Z
20111
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_awpn == itemID )
20112 {
20113 game->forced_awpn = -1;
20114 }
20115
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_xwpn == itemID )
20116 {
20117 game->forced_xwpn = -1;
20118 } //not else if! -Z
20119
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_ywpn == itemID )
20120 {
20121 game->forced_ywpn = -1;
20122 }
20123 11 verifyBothWeapons();
20124 11 return true;
20125 }
20126
20127 case MSGC_SFX:
20128 {
20129 22 sfx(args[0]);
20130 22 return true;
20131 }
20132
20133 case MSGC_MIDI:
20134 {
20135 7 int32_t music = args[0];
20136
20137
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 if(music==0)
20138 1 music_stop();
20139 else
20140 6 jukebox(music+(ZC_MIDI_COUNT-1));
20141
20142 7 return true;
20143 }
20144
20145 case MSGC_FONT:
20146 {
20147 int fontid = args[0];
20148 int oh = text_height(msgfont);
20149 msgfont = get_zc_font(fontid);
20150 int nh = text_height(msgfont);
20151 int mh = std::max(oh,nh);
20152 if(mh > ssc_tile_hei_buf)
20153 ssc_tile_hei_buf = mh;
20154 return true;
20155 }
20156 case MSGC_RUN_FRZ_GENSCR:
20157 {
20158 word scr_id = args[0];
20159 bool force_redraw = args[1]!=0;
20160 if(force_redraw)
20161 {
20162 update_msgstr();
20163 draw_screen();
20164 }
20165 FFCore.runGenericFrozenEngine(scr_id);
20166 return true;
20167 }
20168 case MSGC_DRAWTILE:
20169 {
20170 int32_t tl = args[0];
20171 int32_t cs = args[1];
20172 int32_t t_wid = args[2];
20173 int32_t t_hei = args[3];
20174 int32_t fl = args[4];
20175
20176 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
20177 {
20178 ssc_tile_hei = ssc_tile_hei_buf;
20179 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20180 ssc_tile_hei_buf = -1;
20181 cursor_y += thei + MsgStrings[msgstr].vspace;
20182 if(bottom_margin_clip()) return true;
20183 cursor_x=msg_margins[left];
20184 }
20185
20186 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
20187 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
20188 cursor_x += MsgStrings[msgstr].hspace + t_wid;
20189 return true;
20190 }
20191
20192 case MSGC_GOTOIFRAND:
20193 {
20194 1 int32_t odds = args[0];
20195
20196 1 last_arg = 1;
20197
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!odds || !(zc_oldrand()%odds))
20198 1 goto switched;
20199
20200 return true;
20201 }
20202
20203 case MSGC_GOTOIFGLOBAL:
20204 {
20205 int32_t arg = args[0];
20206 int32_t d = zc_min(7,arg);
20207 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20208 arg = args[1];
20209
20210 if(game->screen_d[s][d] >= arg)
20211 {
20212 last_arg = 2;
20213 goto switched;
20214 }
20215
20216 return true;
20217 }
20218
20219 case MSGC_CHANGEPORTRAIT:
20220 {
20221 return true; //not implemented
20222 }
20223
20224 case MSGC_GOTOIFCREEND:
20225 {
20226 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20227 int32_t screen = args[1];
20228 int32_t reg = args[2];
20229 int32_t val = args[3];
20230 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
20231 {
20232 last_arg = 4;
20233 goto switched;
20234 }
20235 return true;
20236 }
20237
20238 case MSGC_GOTOIF:
20239 {
20240 122 int32_t it = args[0];
20241
20242
3/4
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 35 times.
122 if(unsigned(it)<MAXITEMS && game->item[it])
20243 {
20244 35 last_arg = 1;
20245 35 goto switched;
20246 }
20247
20248 87 return true;
20249 }
20250
20251 case MSGC_GOTOIFCTR:
20252 {
20253
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(game->get_counter(args[0]) >= args[1])
20254 {
20255 14 last_arg = 2;
20256 14 goto switched;
20257 }
20258
20259 14 return true;
20260 }
20261
20262 case MSGC_GOTOIFCTRPC:
20263 {
20264 int32_t counter = args[0];
20265 int32_t amount = (int32_t)((args[1]/100)*game->get_maxcounter(counter));
20266
20267 if(game->get_counter(counter)>=amount)
20268 {
20269 last_arg = 2;
20270 goto switched;
20271 }
20272
20273 return true;
20274 }
20275
20276 case MSGC_GOTOIFTRICOUNT:
20277 {
20278 if(TriforceCount() >= args[0])
20279 {
20280 last_arg = 1;
20281 goto switched;
20282 }
20283
20284 return true;
20285 }
20286
20287 case MSGC_GOTOIFTRI:
20288 {
20289 int32_t lev = args[0];
20290
20291 if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE)
20292 {
20293 last_arg = 1;
20294 goto switched;
20295 }
20296
20297 return true;
20298 }
20299
20300 case MSGC_SETUPMENU:
20301 {
20302 5 msg_menu_data[MNU_CURSOR_TILE] = args[0];
20303 5 msg_menu_data[MNU_CURSOR_CSET] = args[1];
20304 5 msg_menu_data[MNU_CURSOR_WID] = args[2];
20305 5 msg_menu_data[MNU_CURSOR_HEI] = args[3];
20306 5 msg_menu_data[MNU_CURSOR_FLIP] = args[4];
20307 5 return true;
20308 }
20309
20310 case MSGC_MENUCHOICE:
20311 {
20312 18 int32_t pos = args[0];
20313 18 int32_t upos = args[1];
20314 18 int32_t dpos = args[2];
20315 18 int32_t lpos = args[3];
20316 18 int32_t rpos = args[4];
20317
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2 times.
18 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
20318 {
20319 2 ssc_tile_hei = ssc_tile_hei_buf;
20320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20321 2 ssc_tile_hei_buf = -1;
20322 2 cursor_y += thei + MsgStrings[msgstr].vspace;
20323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(bottom_margin_clip()) break;
20324 2 cursor_x=msg_margins[left];
20325 2 }
20326
20327 36 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
20328 18 upos, dpos, lpos, rpos);
20329
20330
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
20331 18 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
20332 18 return true;
20333 }
20334
20335 case MSGC_RUNMENU:
20336 {
20337 5 msg_menu_data[MNU_CHOSEN] = 0;
20338 5 msg_menu_data[MNU_CAN_CONFIRM] = 0;
20339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(menu_options.size() < 1)
20340 return true;
20341 5 do_run_menu = true;
20342 5 return true;
20343 }
20344
20345 case MSGC_GOTOMENUCHOICE:
20346 {
20347 7 int32_t choice = args[0];
20348
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
7 if(msg_menu_data[MNU_CHOSEN] == choice)
20349 {
20350 5 last_arg = 1;
20351 5 goto switched;
20352 }
20353
20354 2 return true;
20355 }
20356
20357 case MSGC_ENDSTRING:
20358 {
20359 3 do_end_str = true;
20360 3 return true;
20361 }
20362 case MSGC_WAIT_ADVANCE:
20363 {
20364 wait_advance = true;
20365 linkedmsgclk = 51;
20366 return true;
20367 }
20368 case MSGC_TRIGSECRETS:
20369 {
20370 bool perm = args[0];
20371 trigger_secrets_for_screen(TriggerSource::SCC, msgscr, false);
20372 if(perm)
20373 setmapflag(msgscr, mSECRET);
20374 return true;
20375 }
20376 case MSGC_TRIG_CMB_COPYCAT:
20377 {
20378 int copy_id = args[0];
20379 if(copy_id == byte(copy_id))
20380 trig_copycat(copy_id);
20381 return true;
20382 }
20383 case MSGC_SETSCREENSTATE:
20384 {
20385 int32_t flag = args[0];
20386 if(unsigned(flag)>=mMAXIND)
20387 {
20388 Z_error("SCC 133: Flag %d is invalid\n", flag);
20389 return true;
20390 }
20391 bool state = args[1];
20392 if(state)
20393 setmapflag(msgscr, 1<<flag);
20394 else
20395 unsetmapflag(msgscr, 1<<flag, true);
20396 return true;
20397 }
20398 case MSGC_SETSCREENSTATER:
20399 {
20400 int32_t map = args[0];
20401 int32_t scrid = args[1];
20402 if(map < 1 || map > map_count)
20403 {
20404 Z_error("SCC 134: Map %d is invalid\n", map);
20405 return true;
20406 }
20407 if(unsigned(scrid)>=0x80)
20408 {
20409 Z_error("SCC 134: Screen %d is invalid\n", scrid);
20410 return true;
20411 }
20412
20413 int32_t flag = args[2];
20414 if(unsigned(flag)>=mMAXIND)
20415 {
20416 Z_error("SCC 134: Flag %d is invalid\n", flag);
20417 return true;
20418 }
20419 bool state = args[3];
20420 if(state)
20421 setmapflag_mi(msgscr, mapind(map,scrid),1<<flag);
20422 else
20423 unsetmapflag_mi(msgscr, mapind(map,scrid),1<<flag,true);
20424 return true;
20425 }
20426 switched:
20427 55 int32_t lev = args[last_arg];
20428
3/4
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
55 if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG)
20429
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 33 times.
54 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
20430 {
20431 setmsg(lev);
20432 }
20433 else
20434 {
20435 55 donewmsg(msgscr, lev);
20436 55 ssc_tile_hei_buf = -1;
20437 }
20438 55 putprices(false);
20439 55 return true;
20440 }
20441
20442 return false;
20443 3293 }
20444
20445 3299 static std::string parsemsgcode2(const StringCommand& command)
20446 {
20447
2/2
✓ Branch 0 taken 3293 times.
✓ Branch 1 taken 6 times.
3299 if (command.code == MSGC_NAME)
20448 {
20449
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 return game->get_name();
20450 }
20451 else
20452 {
20453 3293 parsemsgcode(command);
20454 }
20455
20456
1/2
✓ Branch 0 taken 3293 times.
✗ Branch 1 not taken.
3293 return "";
20457 3299 }
20458
20459 252704 static bool putmsgchar(bool play_sfx)
20460 {
20461 DCHECK(msg_it->state == MsgStr::iterator::CHARACTER);
20462 DCHECK(!msg_it->character.empty());
20463
20464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252704 times.
252704 if (bottom_margin_clip())
20465 return false;
20466
20467 // If the current word would overflow the margins, increment cursor to the next line.
20468 252704 const char* rem_word = msg_it->remaining_word();
20469 252704 int tlength = text_length(msgfont, rem_word) + ((int32_t)strlen(rem_word)*MsgStrings[msgstr].hspace);
20470
4/4
✓ Branch 0 taken 5671 times.
✓ Branch 1 taken 247033 times.
✓ Branch 2 taken 498 times.
✓ Branch 3 taken 5081 times.
258283 if (cursor_x+tlength > (msg_w-msg_margins[right]) &&
20471
4/4
✓ Branch 0 taken 5579 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 5081 times.
✓ Branch 3 taken 92 times.
5671 ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)) ? true : strcmp(rem_word," ")!=0))
20472 {
20473 5579 ssc_tile_hei = ssc_tile_hei_buf;
20474
1/2
✓ Branch 0 taken 5579 times.
✗ Branch 1 not taken.
5579 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20475 5579 ssc_tile_hei_buf = -1;
20476 5579 cursor_y += thei + MsgStrings[msgstr].vspace;
20477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5579 times.
5579 if (bottom_margin_clip()) return false;
20478
20479 5579 cursor_x = msg_margins[left];
20480 5579 }
20481
20482
2/2
✓ Branch 0 taken 34959 times.
✓ Branch 1 taken 217745 times.
252704 if (play_sfx)
20483 217745 sfx(MsgStrings[msgstr].sfx);
20484
20485 // Print the character (unless it's just a space).
20486
2/2
✓ Branch 0 taken 59004 times.
✓ Branch 1 taken 193700 times.
252704 if (msg_it->character != " ")
20487 193700 textout_styled_aligned_ex(msg_txt_bmp_buf, msgfont, msg_it->character.c_str(), cursor_x, cursor_y, msg_shdtype, sstaLEFT, msgcolour, msg_shdcol, -1);
20488
20489 // Move the cursor.
20490 252704 cursor_x += msgfont->vtable->text_length(msgfont, msg_it->character.c_str());
20491
2/2
✓ Branch 0 taken 59004 times.
✓ Branch 1 taken 193700 times.
252704 if (msg_it->character != " ")
20492 193700 cursor_x += MsgStrings[msgstr].hspace;
20493
20494 252704 return true;
20495 252704 }
20496
20497 enum msg_tick_result {msg_tick_exit, msg_tick_break, msg_tick_continue};
20498
20499 static void msg_tick_end(bool disappear = false);
20500 241762 static msg_tick_result msg_tick(bool play_sfx, bool burst_mode)
20501 {
20502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 241762 times.
241762 if (msg_it->done())
20503 return msg_tick_exit;
20504
20505
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 239731 times.
241762 if (!do_run_menu)
20506 {
20507
4/4
✓ Branch 0 taken 239731 times.
✓ Branch 1 taken 3299 times.
✓ Branch 2 taken 239731 times.
✓ Branch 3 taken 3299 times.
243030 while (msg_it->state == MsgStr::iterator::COMMAND && !do_run_menu)
20508 {
20509 3299 bool one_frame_command_delay = !replay_version_check(41);
20510 3299 std::string text = parsemsgcode2(msg_it->command);
20511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3299 times.
3299 if (wait_advance)
20512 break;
20513
20514
2/2
✓ Branch 0 taken 3293 times.
✓ Branch 1 taken 6 times.
3299 if (text.empty())
20515 {
20516
2/4
✓ Branch 0 taken 3293 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3293 times.
✗ Branch 3 not taken.
3293 msg_it->set_buffer("");
20517 // Advance the iterator to run many commands in one frame.
20518
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 3169 times.
3293 if (!one_frame_command_delay)
20519
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 msg_it->next();
20520 3293 }
20521 else
20522 {
20523
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 msg_it->set_buffer(text);
20524
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 msg_it->next();
20525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (one_frame_command_delay)
20526 6 msg_it->post_segment_delay = 1;
20527 }
20528
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3299 times.
3299 }
20529
20530
2/2
✓ Branch 0 taken 3177 times.
✓ Branch 1 taken 236554 times.
239731 if (msg_it->state == MsgStr::iterator::CHARACTER)
20531 {
20532
1/2
✓ Branch 0 taken 236554 times.
✗ Branch 1 not taken.
236554 if (!putmsgchar(play_sfx)) return msg_tick_break;
20533 236554 }
20534 239731 }
20535
20536 241762 bool wait_advance_check_early = !burst_mode;
20537
20538
2/2
✓ Branch 0 taken 78489 times.
✓ Branch 1 taken 163273 times.
241762 if (wait_advance_check_early)
20539 {
20540
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 163272 times.
163273 if (do_end_str)
20541 {
20542 1 msg_tick_end();
20543 1 return msg_tick_exit;
20544 }
20545
20546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 163272 times.
163272 if (wait_advance)
20547 {
20548 msg_it->next();
20549 return msg_tick_exit;
20550 }
20551 163272 }
20552
20553
2/2
✓ Branch 0 taken 239725 times.
✓ Branch 1 taken 2036 times.
241761 if (do_run_menu)
20554 {
20555
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2031 times.
2036 if (runMenuCursor())
20556 {
20557 5 do_run_menu = false;
20558
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if (!burst_mode)
20559 {
20560 2 msg_it->next();
20561 2 return msg_tick(play_sfx, burst_mode);
20562 }
20563 3 }
20564 2031 else return msg_tick_break;
20565 3 }
20566
20567 239728 msg_it->next();
20568
20569
2/2
✓ Branch 0 taken 161773 times.
✓ Branch 1 taken 77955 times.
239728 if (!wait_advance_check_early)
20570 {
20571
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 77953 times.
77955 if (do_end_str)
20572 {
20573 2 msg_tick_end();
20574 2 return msg_tick_exit;
20575 }
20576
20577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77953 times.
77953 if (wait_advance)
20578 return msg_tick_exit;
20579 77953 }
20580
20581
4/4
✓ Branch 0 taken 4007 times.
✓ Branch 1 taken 235719 times.
✓ Branch 2 taken 2017 times.
✓ Branch 3 taken 1990 times.
239726 if (msg_it->done() && MsgStrings[msgstr].nextstring)
20582 {
20583
1/2
✓ Branch 0 taken 2017 times.
✗ Branch 1 not taken.
2017 if (MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20584 setmsg(MsgStrings[msgstr].nextstring);
20585 2017 }
20586
20587 239726 return msg_tick_continue;
20588 241762 }
20589
20590 165560 static void msg_tick_end(bool disappear)
20591 {
20592
2/2
✓ Branch 0 taken 164547 times.
✓ Branch 1 taken 1013 times.
165560 if (disappear)
20593 1013 goto disappear;
20594
20595 // Done printing the string
20596
8/8
✓ Branch 0 taken 164544 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 163047 times.
✓ Branch 3 taken 1497 times.
✓ Branch 4 taken 159021 times.
✓ Branch 5 taken 4026 times.
✓ Branch 6 taken 159021 times.
✓ Branch 7 taken 4026 times.
164547 if (do_end_str || !do_run_menu && (msg_it->done() || bottom_margin_clip()) && !linkedmsgclk)
20597 {
20598
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4026 times.
4029 if(!do_end_str)
20599 {
20600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4026 times.
4026 while (msg_it->state == MsgStr::iterator::COMMAND)
20601 {
20602 parsemsgcode2(msg_it->command);
20603 msg_it->next();
20604 }
20605 4026 }
20606
20607 // Go to next string, or make it disappear by going to string 0.
20608
5/6
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 2019 times.
✓ Branch 2 taken 996 times.
✓ Branch 3 taken 1014 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 996 times.
4029 if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str)
20609 {
20610 3033 linkedmsgclk=do_end_str?1:51;
20611 3033 }
20612
20613
2/2
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 2019 times.
4029 if(MsgStrings[msgstr].nextstring==0)
20614 {
20615
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 996 times.
2010 if(!get_qr(qr_MSGDISAPPEAR))
20616 996 {
20617 disappear:
20618 2009 msg_active = false;
20619 2009 Hero.finishedmsg();
20620 2009 }
20621
20622
2/2
✓ Branch 0 taken 3010 times.
✓ Branch 1 taken 13 times.
3023 if(repaircharge)
20623 {
20624
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 game->change_drupy(-(cur_screen >= 128 ? special_warp_return_scr : msgscr)->catchall);
20625 13 repaircharge = 0;
20626 13 }
20627
20628
2/2
✓ Branch 0 taken 3021 times.
✓ Branch 1 taken 2 times.
3023 if(adjustmagic)
20629 {
20630
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(get_qr(qr_OLD_HALF_MAGIC))
20631 {
20632
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(game->get_magicdrainrate())
20633 2 game->set_magicdrainrate(1);
20634 2 }
20635 else if(game->get_magicdrainrate() > 1)
20636 {
20637 game->set_magicdrainrate(game->get_magicdrainrate()/2);
20638 }
20639 2 adjustmagic = false;
20640 2 sfx(WAV_SCALE);
20641
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20642 2 }
20643
20644
2/2
✓ Branch 0 taken 3021 times.
✓ Branch 1 taken 2 times.
3023 if(learnslash)
20645 {
20646 2 game->set_canslash(1);
20647 2 learnslash = false;
20648 2 sfx(WAV_SCALE);
20649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20650 2 }
20651 3023 }
20652 5042 }
20653 165560 }
20654
20655 6228 static void msg_consume_spaces()
20656 {
20657
2/2
✓ Branch 0 taken 6228 times.
✓ Branch 1 taken 16150 times.
22378 while (msg_it->character == " ")
20658 {
20659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16150 times.
16150 if (!putmsgchar(false)) break;
20660
20661 // Advance the iterator.
20662 16150 msg_it->next();
20663
20664 // The "Continue From Previous" feature
20665
1/2
✓ Branch 0 taken 16150 times.
✗ Branch 1 not taken.
16150 if (msg_it->state == MsgStr::iterator::DONE)
20666 {
20667 if(MsgStrings[msgstr].nextstring)
20668 {
20669 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20670 {
20671 setmsg(MsgStrings[msgstr].nextstring);
20672 }
20673 }
20674 }
20675 }
20676 6228 }
20677
20678 14618334 void putmsg()
20679 {
20680
2/2
✓ Branch 0 taken 681711 times.
✓ Branch 1 taken 13936623 times.
14618334 if(!msgorig) msgorig=msgstr;
20681
20682
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14618334 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14618334 if(wait_advance && linkedmsgclk < 1)
20683 linkedmsgclk = 1;
20684
2/2
✓ Branch 0 taken 14340154 times.
✓ Branch 1 taken 278180 times.
14618334 if(linkedmsgclk>0)
20685 {
20686
2/2
✓ Branch 0 taken 126729 times.
✓ Branch 1 taken 151451 times.
278180 if(linkedmsgclk==1)
20687 {
20688
6/6
✓ Branch 0 taken 126726 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 123816 times.
✓ Branch 3 taken 2910 times.
✓ Branch 4 taken 118 times.
✓ Branch 5 taken 123698 times.
126729 if(do_end_str||cAbtn()||cBbtn())
20689 {
20690 3031 do_end_str = false;
20691 3031 linkedmsgclk = 0;
20692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3031 times.
3031 if(wait_advance)
20693 {
20694 wait_advance = false;
20695 }
20696 else
20697 {
20698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3031 times.
3031 if (!msgscr) msgscr = hero_scr;
20699 3031 msgstr=MsgStrings[msgstr].nextstring;
20700 3031 ssc_tile_hei_buf = -1;
20701
3/4
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 2018 times.
✓ Branch 2 taken 1013 times.
✗ Branch 3 not taken.
3031 if(!msgstr && enqueued_str)
20702 {
20703 msgstr = enqueued_str;
20704 enqueued_str = 0;
20705 }
20706
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 2018 times.
3031 if(!msgstr)
20707 {
20708 1013 msgfont=get_zc_font(font_zfont);
20709
20710
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1009 times.
1013 if(msgscr->room!=rGRUMBLE)
20711 1009 blockpath=false;
20712
20713 1013 dismissmsg();
20714 1013 msg_tick_end(true);
20715 1013 return;
20716 }
20717
20718 2018 donewmsg(msgscr, msgstr);
20719 2018 putprices(false);
20720 }
20721 2018 }
20722 125716 }
20723 else
20724 {
20725 151451 --linkedmsgclk;
20726 }
20727 277167 }
20728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14617321 times.
14617321 if(wait_advance) return; //Waiting for buttonpress
20729
20730
9/10
✓ Branch 0 taken 14615366 times.
✓ Branch 1 taken 1955 times.
✓ Branch 2 taken 676780 times.
✓ Branch 3 taken 13938586 times.
✓ Branch 4 taken 263442 times.
✓ Branch 5 taken 413338 times.
✓ Branch 6 taken 259417 times.
✓ Branch 7 taken 4025 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 259417 times.
14617321 if(!do_run_menu && (!msgstr || !msg_it || msg_it->done() || bottom_margin_clip()))
20731 {
20732
2/2
✓ Branch 0 taken 13938586 times.
✓ Branch 1 taken 417363 times.
14355949 if(!msgstr)
20733 13938586 msgorig=0;
20734
20735 14355949 msg_active = false;
20736 14355949 msg_it.reset();
20737 14355949 return;
20738 }
20739
20740
1/2
✓ Branch 0 taken 261372 times.
✗ Branch 1 not taken.
261372 if (!msg_it)
20741 return;
20742
20743 261372 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
20744
20745
2/2
✓ Branch 0 taken 257323 times.
✓ Branch 1 taken 4049 times.
261372 if (msg_it->state == MsgStr::iterator::NOT_STARTED)
20746 {
20747 4049 msg_it->next();
20748 4049 msg_consume_spaces();
20749 4049 }
20750
20751 // If the player is holding down the B button, or if msgspeed is 0, process as many characters
20752 // as possible. This skips the character-by-character animation that usually renders a string
20753 // slowly over many frames.
20754
4/4
✓ Branch 0 taken 1381 times.
✓ Branch 1 taken 259991 times.
✓ Branch 2 taken 897 times.
✓ Branch 3 taken 259094 times.
261372 if ((cBbtn() && get_qr(qr_ALLOWMSGBYPASS)) || msgspeed == 0)
20755 {
20756
2/2
✓ Branch 0 taken 1274 times.
✓ Branch 1 taken 78499 times.
80231 while (!msg_it->done())
20757 {
20758
5/6
✓ Branch 0 taken 20654 times.
✓ Branch 1 taken 57845 times.
✓ Branch 2 taken 20644 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 20644 times.
✗ Branch 5 not taken.
78499 if (msgspeed && !(cBbtn() && get_qr(qr_ALLOWMSGBYPASS)))
20759 10 goto breakout; // break out if message speed was changed to non-zero
20760
20761 78489 auto tick = msg_tick(msg_it->character != " ", true);
20762
2/2
✓ Branch 0 taken 77955 times.
✓ Branch 1 taken 534 times.
78489 if (tick == msg_tick_break)
20763 534 break;
20764
2/2
✓ Branch 0 taken 77953 times.
✓ Branch 1 taken 2 times.
77955 if (tick == msg_tick_exit)
20765 2 return;
20766 }
20767
20768
2/2
✓ Branch 0 taken 534 times.
✓ Branch 1 taken 1274 times.
1808 if (!do_run_menu)
20769 {
20770 1274 msgclk = 72;
20771 1274 }
20772 1808 }
20773 else
20774 259094 {
20775 breakout:
20776 259104 word tempspeed = msgspeed;
20777
2/2
✓ Branch 0 taken 258141 times.
✓ Branch 1 taken 963 times.
259104 if (do_run_menu)
20778 963 tempspeed = 0;
20779
6/6
✓ Branch 0 taken 207843 times.
✓ Branch 1 taken 51261 times.
✓ Branch 2 taken 121553 times.
✓ Branch 3 taken 86290 times.
✓ Branch 4 taken 111476 times.
✓ Branch 5 taken 10077 times.
259104 if(((msgclk++)%(tempspeed+1)<tempspeed)&&((!cAbtn())||(!get_qr(qr_ALLOWFASTMSG))))
20780 96367 return;
20781 }
20782
20783 // Process the next msg tick.
20784 // This will either print a single character, or process a single string command (with one
20785 // exception).
20786
3/4
✓ Branch 0 taken 163271 times.
✓ Branch 1 taken 1274 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 163271 times.
164545 if (!msg_it->done() && !bottom_margin_clip())
20787 {
20788 // This may run an additional tick in the case of a string menu finishing: the first
20789 // tick wraps up the menu, and then a second tick processes the next character or command.
20790 163271 auto tick = msg_tick(true, false);
20791
2/2
✓ Branch 0 taken 1497 times.
✓ Branch 1 taken 161774 times.
163271 if (tick == msg_tick_break)
20792 {
20793 1497 msg_tick_end();
20794 1497 return;
20795 }
20796
2/2
✓ Branch 0 taken 161773 times.
✓ Branch 1 taken 1 times.
161774 if (tick == msg_tick_exit)
20797 1 return;
20798
20799 // If the next two characters are spaces, consume all upcoming spaces now.
20800
13/20
✓ Branch 0 taken 2752 times.
✓ Branch 1 taken 159021 times.
✓ Branch 2 taken 159021 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26249 times.
✓ Branch 5 taken 132772 times.
✓ Branch 6 taken 26249 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 26249 times.
✓ Branch 10 taken 135524 times.
✓ Branch 11 taken 26249 times.
✓ Branch 12 taken 2752 times.
✓ Branch 13 taken 159021 times.
✓ Branch 14 taken 159594 times.
✓ Branch 15 taken 2179 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
188022 if (!msg_it->done() && msg_it->peek(0) == " " && msg_it->peek(1) == " ")
20801 2179 msg_consume_spaces();
20802 161773 }
20803
20804 163047 msg_tick_end();
20805 14617876 }
20806
20807 124732 int32_t message_more_y()
20808 {
20809 //Is the flag ticked, do we really want a message more y larger than 160?
20810
5/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 124704 times.
✓ Branch 2 taken 124732 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124704 times.
✓ Branch 5 taken 28 times.
124732 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
20811 124732 msgy+=playing_field_offset;
20812 124732 return msgy;
20813 }
20814
20815 /*** Collision detection & handling ***/
20816
20817 14306378 void clear_script_one_frame_conditions()
20818 {
20819
2/2
✓ Branch 0 taken 38991403 times.
✓ Branch 1 taken 14306378 times.
53297781 for(int32_t j=0; j<guys.Count(); j++)
20820 {
20821 38991403 enemy *e = (enemy*)guys.spr(j);
20822
2/2
✓ Branch 0 taken 662853851 times.
✓ Branch 1 taken 38991403 times.
701845254 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
20823 38991403 }
20824 14306378 }
20825
20826 4883715 void check_enemy_lweapon_collision(weapon *w)
20827 {
20828
8/8
✓ Branch 0 taken 4267271 times.
✓ Branch 1 taken 616444 times.
✓ Branch 2 taken 3271483 times.
✓ Branch 3 taken 995788 times.
✓ Branch 4 taken 3209341 times.
✓ Branch 5 taken 62142 times.
✓ Branch 6 taken 16738 times.
✓ Branch 7 taken 3192603 times.
4883715 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
20829 {
20830
2/2
✓ Branch 0 taken 3176788 times.
✓ Branch 1 taken 11214738 times.
14391526 for(int32_t j=0; j<guys.Count(); j++)
20831 {
20832 11214738 enemy *e = (enemy*)guys.spr(j);
20833
20834 11214738 bool didhit = e->hit(w);
20835 //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
20836 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
20837
2/2
✓ Branch 0 taken 10993873 times.
✓ Branch 1 taken 220865 times.
11214738 if(didhit)
20838 {
20839 // !(e->stunclk)
20840 220865 int32_t h = e->takehit(w);
20841
2/2
✓ Branch 0 taken 186989 times.
✓ Branch 1 taken 33876 times.
220865 if (h < 0) // hitby code
20842 {
20843 33876 int indx = Lwpns.find(w);
20844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33876 times.
33876 if(indx > -1)
20845 33876 e->hitby[HIT_BY_LWEAPON] = indx+1;
20846 33876 e->hitby[HIT_BY_LWEAPON_UID] = w->getUID();
20847 33876 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
20848
2/2
✓ Branch 0 taken 31471 times.
✓ Branch 1 taken 2405 times.
33876 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].type;
20849 2405 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
20850 33876 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
20851 33876 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
20852 //we may need to handle this in special cases. -Z
20853 // arrow item pierce flag, for example -Em
20854 33876 }
20855
20856
2/2
✓ Branch 0 taken 33876 times.
✓ Branch 1 taken 186989 times.
220865 if(h < 0) // hit, check if weapon is "out of pierces"
20857 33876 w->hit_pierce(e, h);
20858
2/2
✓ Branch 0 taken 176579 times.
✓ Branch 1 taken 10410 times.
186989 else if(h > 0) // blocked
20859 10410 w->onhit(false, e, h);
20860
2/2
✓ Branch 0 taken 218191 times.
✓ Branch 1 taken 2674 times.
220865 if(abs(h) == 2)
20861 2674 break; // some enemy classes force a weapon hitting them to "wait a frame"
20862 218191 }
20863
20864
2/2
✓ Branch 0 taken 11198923 times.
✓ Branch 1 taken 13141 times.
11212064 if(w->Dead())
20865 {
20866 13141 break;
20867 }
20868 11198923 }
20869
20870 // Item flags added in 2.55:
20871 // BRang/HShot/Arrows item_flag4 is "Pick up anything" (port of qr_BRANGPICKUP)
20872 // BRang/HShot item_flag5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
20873 // Arrows item_flag2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
20874 // -Em
20875
6/6
✓ Branch 0 taken 2738060 times.
✓ Branch 1 taken 454543 times.
✓ Branch 2 taken 2693374 times.
✓ Branch 3 taken 44686 times.
✓ Branch 4 taken 44765 times.
✓ Branch 5 taken 2648609 times.
3192603 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
20876 {
20877 543994 int32_t itype, pitem = w->parentitem;
20878
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 454543 times.
✓ Branch 2 taken 44765 times.
✓ Branch 3 taken 44686 times.
543994 switch(w->id)
20879 {
20880 454543 case wBrang: itype = itype_brang; break;
20881 44765 case wArrow: itype = itype_arrow; break;
20882 case wHookshot:
20883 44686 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
20884 44686 break;
20885 }
20886
2/2
✓ Branch 0 taken 538953 times.
✓ Branch 1 taken 5041 times.
543994 if(pitem < 0) pitem = current_item_id(itype);
20887
5/6
✓ Branch 0 taken 44686 times.
✓ Branch 1 taken 499308 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 44586 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
543994 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & item_flag9))
20888 { //Swap with item
20889 for(int32_t j=0; j<items.Count(); j++)
20890 {
20891 if(items.spr(j)->hit(w))
20892 {
20893 item *theItem = ((item*)items.spr(j));
20894 bool priced = theItem->PriceIndex >-1;
20895 bool isKey = itemsbuf[theItem->id].type==itype_key||itemsbuf[theItem->id].type==itype_lkey;
20896 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
20897 || (((itemsbuf[w->parentitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
20898 {
20899 if(!Hero.switchhookclk)
20900 {
20901 hooked_comborpos = rpos_t::None;
20902 hooked_layerbits = 0;
20903 switching_object = theItem;
20904 theItem->switch_hooked = true;
20905 w->misc = 2;
20906 w->step = 0;
20907 theItem->clk2=256;
20908 Hero.doSwitchHook(game->get_switchhookstyle());
20909 if(QMisc.miscsfx[sfxSWITCHED])
20910 sfx(QMisc.miscsfx[sfxSWITCHED],pan(w->x));
20911 }
20912 }
20913 }
20914 }
20915 }
20916
6/6
✓ Branch 0 taken 44765 times.
✓ Branch 1 taken 499229 times.
✓ Branch 2 taken 374939 times.
✓ Branch 3 taken 330174 times.
✓ Branch 4 taken 499229 times.
✓ Branch 5 taken 330174 times.
543994 else if((w->id==wArrow&&itemsbuf[pitem].flags & item_flag2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & item_flag5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
20917 {
20918
2/2
✓ Branch 0 taken 88886 times.
✓ Branch 1 taken 374939 times.
463825 for(int32_t j=0; j<items.Count(); j++)
20919 {
20920
2/2
✓ Branch 0 taken 83988 times.
✓ Branch 1 taken 4898 times.
88886 if(items.spr(j)->hit(w))
20921 {
20922 4898 item *theItem = ((item*)items.spr(j));
20923 4898 bool priced = theItem->PriceIndex >-1;
20924
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 4766 times.
4898 bool isKey = itemsbuf[theItem->id].type==itype_key||itemsbuf[theItem->id].type==itype_lkey;
20925
5/8
✓ Branch 0 taken 4898 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3789 times.
✓ Branch 5 taken 1109 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2065 times.
6963 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
20926
4/6
✓ Branch 0 taken 3174 times.
✓ Branch 1 taken 2065 times.
✓ Branch 2 taken 3174 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3174 times.
4898 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey))&& !priced)))
20927 {
20928
1/2
✓ Branch 0 taken 1724 times.
✗ Branch 1 not taken.
5854 if(itemsbuf[theItem->id].collect_script)
20929 {
20930 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
20931 }
20932
20933 1724 Hero.checkitems(j);
20934 1724 }
20935 4898 }
20936 88886 }
20937 374939 }
20938
2/2
✓ Branch 0 taken 15674 times.
✓ Branch 1 taken 153381 times.
829403 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
20939 {
20940
2/2
✓ Branch 0 taken 36900 times.
✓ Branch 1 taken 153381 times.
190281 for(int32_t j=0; j<items.Count(); j++)
20941 {
20942
2/2
✓ Branch 0 taken 28212 times.
✓ Branch 1 taken 8688 times.
36900 if(items.spr(j)->hit(w))
20943 {
20944 8688 item *theItem = ((item*)items.spr(j));
20945 8688 bool priced = theItem->PriceIndex >-1;
20946
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8681 times.
8688 bool isKey = itemsbuf[theItem->id].type==itype_key||itemsbuf[theItem->id].type==itype_lkey;
20947
4/6
✓ Branch 0 taken 8688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8454 times.
✓ Branch 5 taken 234 times.
8688 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
20948
5/10
✓ Branch 0 taken 7273 times.
✓ Branch 1 taken 1181 times.
✓ Branch 2 taken 1415 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1415 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1415 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8688 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
20949 {
20950 7273 int32_t pickup = theItem->pickup;
20951 7273 int32_t id2 = theItem->id;
20952 7273 int32_t pstr = theItem->pstring;
20953 7273 int32_t pstr_flags = theItem->pickup_string_flags;
20954
20955 7273 std::vector<int32_t> &ev = FFCore.eventData;
20956 7273 ev.clear();
20957 7273 ev.push_back(id2*10000);
20958 7273 ev.push_back(pickup*10000);
20959 7273 ev.push_back(pstr*10000);
20960 7273 ev.push_back(pstr_flags*10000);
20961 7273 ev.push_back(0);
20962 7273 ev.push_back(theItem->getUID());
20963 7273 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
20964 7273 ev.push_back(w->getUID());
20965
20966 7273 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
20967 7273 bool nullify = ev[4] != 0;
20968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7273 times.
7273 if(nullify) continue;
20969
2/2
✓ Branch 0 taken 1076 times.
✓ Branch 1 taken 6197 times.
7273 if(w->id == wBrang)
20970 {
20971 6197 w->onhit(false);
20972 6197 }
20973
20974
2/2
✓ Branch 0 taken 6775 times.
✓ Branch 1 taken 498 times.
7273 if(w->dragging==-1)
20975 {
20976 498 w->dead=1;
20977 498 theItem->clk2=256;
20978 498 w->dragging=j;
20979 498 theItem->is_dragged = true;
20980 498 }
20981 7273 }
20982 8688 }
20983 36900 }
20984 153381 }
20985 543994 }
20986 3192603 }
20987 4883715 }
20988 14304194 void check_collisions()
20989 {
20990
2/2
✓ Branch 0 taken 4883680 times.
✓ Branch 1 taken 14304194 times.
19187874 for(uint q = 0; q < Lwpns.Count(); ++q)
20991 4883680 check_enemy_lweapon_collision((weapon*)Lwpns.spr(q));
20992 14304194 }
20993
20994 14306378 void dragging_item()
20995 {
20996
2/2
✓ Branch 0 taken 5000289 times.
✓ Branch 1 taken 14306378 times.
19306667 for(int32_t i=0; i<Lwpns.Count(); i++)
20997 {
20998 5000289 weapon *w = (weapon*)Lwpns.spr(i);
20999
21000
4/4
✓ Branch 0 taken 4537151 times.
✓ Branch 1 taken 463138 times.
✓ Branch 2 taken 4844927 times.
✓ Branch 3 taken 155362 times.
5000289 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & item_flag5)//item_flag5 is a port for qr_Z3BRANG_HSHOT
21001 {
21002
3/4
✓ Branch 0 taken 7247 times.
✓ Branch 1 taken 148115 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7247 times.
155362 if(w->dragging>=0 && w->dragging<items.Count())
21003 {
21004 7247 item* dragItem = (item*)items.spr(w->dragging);
21005 7247 dragItem->x=w->x;
21006 7247 dragItem->y=w->y;
21007
21008 // Drag the Fairy enemy as well as the Fairy item
21009 7247 int32_t id = dragItem->id;
21010
21011
4/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 6828 times.
✓ Branch 2 taken 404 times.
✓ Branch 3 taken 15 times.
7247 if(itemsbuf[id].type ==itype_fairy && itemsbuf[id].misc3)
21012 {
21013 404 movefairynew2(w->x,w->y,*dragItem);
21014 404 }
21015 7247 }
21016 155362 }
21017 5000289 }
21018 14306378 }
21019
21020 57 int32_t more_carried_items(int screen)
21021 {
21022 57 int32_t hasmorecarries = 0;
21023
21024
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 57 times.
121 for(int32_t i=0; i<items.Count(); i++)
21025 {
21026 64 auto spr = (item*)items.spr(i);
21027
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 57 times.
64 if (spr->screen_spawned == screen && (spr->pickup & ipENEMY))
21028 {
21029 57 hasmorecarries++;
21030 57 }
21031 64 }
21032
21033 57 return hasmorecarries;
21034 }
21035
21036 36535 static int count_guys_from_screen(int screen)
21037 {
21038 36535 int count = 0;
21039
2/2
✓ Branch 0 taken 237871 times.
✓ Branch 1 taken 36535 times.
274406 for (int i=0; i < guys.Count(); i++)
21040 {
21041
2/2
✓ Branch 0 taken 36538 times.
✓ Branch 1 taken 201333 times.
237871 if (((enemy*)guys.spr(i))->screen_spawned == screen)
21042 201333 count += 1;
21043 237871 }
21044 36535 return count;
21045 }
21046
21047 // messy code to do the enemy-carrying-the-item thing
21048 14694306 static void roaming_item(mapscr* scr)
21049 {
21050 14694306 int screen = scr->screen;
21051 14694306 auto& state = get_screen_state(screen);
21052
4/4
✓ Branch 0 taken 14657833 times.
✓ Branch 1 taken 36473 times.
✓ Branch 2 taken 14657771 times.
✓ Branch 3 taken 36535 times.
14694306 if (!(state.item_state == ScreenItemState::CarriedByEnemy || state.item_state == ScreenItemState::MustGiveToEnemy) || !state.loaded_enemies)
21053 14657771 return;
21054
21055 // All enemies already dead upon entering a room?
21056
1/2
✓ Branch 0 taken 36535 times.
✗ Branch 1 not taken.
36535 if (count_guys_from_screen(screen) == 0)
21057 {
21058 return;
21059 }
21060
21061 36535 int guycarryingitem = -1;
21062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84544 times.
84544 for(int32_t j=0; j<guys.Count(); j++)
21063 {
21064 84544 enemy* e = (enemy*)guys.spr(j);
21065
4/4
✓ Branch 0 taken 62850 times.
✓ Branch 1 taken 21694 times.
✓ Branch 2 taken 26315 times.
✓ Branch 3 taken 36535 times.
84544 if (e->screen_spawned == screen && e->itemguy)
21066 {
21067 36535 guycarryingitem=j;
21068 36535 break;
21069 }
21070 48009 }
21071
21072
2/2
✓ Branch 0 taken 36458 times.
✓ Branch 1 taken 77 times.
36535 if (state.item_state == ScreenItemState::MustGiveToEnemy)
21073 {
21074
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(guycarryingitem == -1) //This happens when "default enemies" such as
21075 {
21076 return; //eSHOOTFBALL are alive but enemies from the list
21077 } //are not. Defer to HeroClass::checkspecial().
21078
21079 77 int32_t Item=scr->item;
21080
21081 77 state.item_state = ScreenItemState::None;
21082
21083
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
21084 {
21085 154 auto [x, y] = translate_screen_coordinates_to_world(screen);
21086 218 additem(x,y,Item,ipENEMY+ipONETIME+ipBIGRANGE
21087
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 13 times.
77 + (((scr->flags3&fHOLDITEM) || (itemsbuf[Item].type==itype_triforcepiece)) ? ipHOLDUP : 0)
21088 );
21089 77 ((item*)items.spr(items.Count() - 1))->screen_spawned = screen;
21090 77 state.item_state = ScreenItemState::CarriedByEnemy;
21091 77 }
21092 else
21093 {
21094 return;
21095 }
21096 77 }
21097
21098
2/2
✓ Branch 0 taken 46044 times.
✓ Branch 1 taken 36535 times.
82579 for(int32_t i=0; i<items.Count(); i++)
21099 {
21100
4/4
✓ Branch 0 taken 42433 times.
✓ Branch 1 taken 3611 times.
✓ Branch 2 taken 5898 times.
✓ Branch 3 taken 36535 times.
46044 if(((item*)items.spr(i))->pickup&ipENEMY && ((item*)items.spr(i))->screen_spawned == screen)
21101 {
21102
2/2
✓ Branch 0 taken 22240 times.
✓ Branch 1 taken 14295 times.
36535 if(get_qr(qr_HIDECARRIEDITEMS))
21103 {
21104 22240 items.spr(i)->x = -128; // Awfully inelegant, innit?
21105 22240 items.spr(i)->y = -128;
21106 22240 }
21107
2/4
✓ Branch 0 taken 14295 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14295 times.
14295 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
21108 {
21109
1/2
✓ Branch 0 taken 14295 times.
✗ Branch 1 not taken.
14295 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
21110 {
21111 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
21112 {
21113 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8;
21114 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10;
21115 }
21116 else
21117 {
21118 if(guys.spr(guycarryingitem)->extend >= 3)
21119 {
21120 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
21121 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
21122 }
21123 else
21124 {
21125 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21126 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21127 }
21128 }
21129 items.spr(i)->z = guys.spr(guycarryingitem)->z;
21130 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21131 }
21132 else
21133 {
21134 14295 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21135 14295 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21136 14295 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21137 }
21138 14295 }
21139 36535 }
21140 46044 }
21141 14694306 }
21142
21143 14306378 void roaming_item()
21144 {
21145 29000684 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
21146 14694306 roaming_item(scr);
21147 14694306 });
21148 14306378 }
21149
21150 bool enemy::IsBigAnim()
21151 {
21152 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
21153 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
21154 || anim == a4FRM8DIRB);
21155 }
21156 2418852 int32_t enemy::getFlashingCSet()
21157 {
21158 //Special cset for the dying sprite
21159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2418852 times.
2418852 if(dying)
21160 {
21161 if (!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading == fade_blue_poof)
21162 return wpnsbuf[spr_death].csets & 15;
21163 else
21164 return (((clk2 + 5) >> 1) & 3) + 6;
21165 }
21166
21167 //Normal cset
21168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2418852 times.
2418852 if (hclk <= 0)
21169 {
21170 //Special cset for the flashing animation
21171 if (flags & guy_flashing)
21172 return (frame & 3) + 6;
21173 return cs;
21174 }
21175
21176 //Hurt animations
21177
2/2
✓ Branch 0 taken 3888 times.
✓ Branch 1 taken 2414964 times.
2418852 if(type==eeGANON)
21178 3888 return (((hclk-1)>>1)&3)+6;
21179
4/4
✓ Branch 0 taken 2245020 times.
✓ Branch 1 taken 169944 times.
✓ Branch 2 taken 487138 times.
✓ Branch 3 taken 1757882 times.
2414964 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
21180 1757882 return (((hclk-1)>>1)&3)+6;
21181
21182 657082 return cs;
21183 2418852 }
21184
21185 81975581 bool enemy::is_hitflickerframe(bool olddrawing)
21186 {
21187
6/6
✓ Branch 0 taken 81947077 times.
✓ Branch 1 taken 28504 times.
✓ Branch 2 taken 3972522 times.
✓ Branch 3 taken 77974555 times.
✓ Branch 4 taken 3199831 times.
✓ Branch 5 taken 772691 times.
81975581 if (type == eeGANON || !hclk || !get_qr(qr_ENEMIESFLICKER))
21188 81202890 return false;
21189
21190
3/4
✓ Branch 0 taken 496051 times.
✓ Branch 1 taken 276640 times.
✓ Branch 2 taken 496051 times.
✗ Branch 3 not taken.
772691 if (!olddrawing && !getCanFlicker())
21191 return false;
21192
21193 772691 int32_t fr = game->get_spriteflickerspeed();
21194
1/2
✓ Branch 0 taken 772691 times.
✗ Branch 1 not taken.
772691 if (fr == 0)
21195 return true;
21196 772691 return frame % (fr * 2) < fr;
21197 81975581 }
21198
21199 const char *old_guy_string[OLDMAXGUYS] =
21200 {
21201 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
21202 // 020
21203 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
21204 // 025
21205 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
21206 // 030
21207 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
21208 // 035
21209 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
21210 // 040
21211 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
21212 // 045
21213 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
21214 // 050
21215 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
21216 // 055
21217 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
21218 // 060
21219 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
21220 // 065
21221 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
21222 // 070
21223 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
21224 // 075
21225 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
21226 // 080
21227 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
21228 // 085
21229 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
21230 // 090
21231 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
21232 // 095
21233 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
21234 // 100
21235 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
21236 // 105
21237 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
21238 // 110
21239 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
21240 // 115
21241 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
21242 // 120
21243 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
21244 // 125
21245 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
21246 // 130
21247 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
21248 // 135
21249 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
21250 // 140
21251 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
21252 // 145
21253 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
21254 // 150
21255 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
21256 // 155
21257 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
21258 // 160
21259 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
21260 // 165
21261 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
21262 // 170
21263 "Pols Voice (Magic)", "Pols Voice (Whistle)", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
21264 // 175
21265 "Grappler Bug (HP) ", "Grappler Bug (MP) "
21266 };
21267
21268 15687886 int32_t enemy::get_dmisc(byte index)
21269 {
21270
20/33
✓ Branch 0 taken 14611 times.
✓ Branch 1 taken 15885 times.
✓ Branch 2 taken 3236 times.
✓ Branch 3 taken 7390 times.
✓ Branch 4 taken 2144 times.
✓ Branch 5 taken 1794 times.
✓ Branch 6 taken 1051 times.
✓ Branch 7 taken 250 times.
✓ Branch 8 taken 1852 times.
✓ Branch 9 taken 1822 times.
✓ Branch 10 taken 7793452 times.
✓ Branch 11 taken 7597384 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 308 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 40 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 216 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 884 times.
✓ Branch 25 taken 1120 times.
✓ Branch 26 taken 331 times.
✓ Branch 27 taken 238061 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 6055 times.
✗ Branch 32 not taken.
15687886 switch (index)
21271 {
21272 14611 case 0: return dmisc1;
21273 15885 case 1: return dmisc2;
21274 3236 case 2: return dmisc3;
21275 7390 case 3: return dmisc4;
21276 2144 case 4: return dmisc5;
21277 1794 case 5: return dmisc6;
21278 1051 case 6: return dmisc7;
21279 250 case 7: return dmisc8;
21280 1852 case 8: return dmisc9;
21281 1822 case 9: return dmisc10;
21282 7793452 case 10: return dmisc11;
21283 7597384 case 11: return dmisc12;
21284 case 12: return dmisc13;
21285 308 case 13: return dmisc14;
21286 case 14: return dmisc15;
21287 40 case 15: return dmisc16;
21288 case 16: return dmisc17;
21289 216 case 17: return dmisc18;
21290 case 18: return dmisc19;
21291 case 19: return dmisc20;
21292 case 20: return dmisc21;
21293 case 21: return dmisc22;
21294 case 22: return dmisc23;
21295 case 23: return dmisc24;
21296 884 case 24: return dmisc25;
21297 1120 case 25: return dmisc26;
21298 331 case 26: return dmisc27;
21299 238061 case 27: return dmisc28;
21300 case 28: return dmisc29;
21301 case 29: return dmisc30;
21302 case 30: return dmisc31;
21303 6055 case 31: return dmisc32;
21304 }
21305
21306 return 0;
21307 15687886 }
21308
21309 312 void enemy::set_dmisc(byte index, int32_t value)
21310 {
21311
3/33
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 4 times.
✓ Branch 27 taken 24 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 284 times.
✗ Branch 32 not taken.
312 switch (index)
21312 {
21313 case 0: dmisc1 = value; break;
21314 case 1: dmisc2 = value; break;
21315 case 2: dmisc3 = value; break;
21316 case 3: dmisc4 = value; break;
21317 case 4: dmisc5 = value; break;
21318 case 5: dmisc6 = value; break;
21319 case 6: dmisc7 = value; break;
21320 case 7: dmisc8 = value; break;
21321 case 8: dmisc9 = value; break;
21322 case 9: dmisc10 = value; break;
21323 case 10: dmisc11 = value; break;
21324 case 11: dmisc12 = value; break;
21325 case 12: dmisc13 = value; break;
21326 case 13: dmisc14 = value; break;
21327 case 14: dmisc15 = value; break;
21328 case 15: dmisc16 = value; break;
21329 case 16: dmisc17 = value; break;
21330 case 17: dmisc18 = value; break;
21331 case 18: dmisc19 = value; break;
21332 case 19: dmisc20 = value; break;
21333 case 20: dmisc21 = value; break;
21334 case 21: dmisc22 = value; break;
21335 case 22: dmisc23 = value; break;
21336 case 23: dmisc24 = value; break;
21337 case 24: dmisc25 = value; break;
21338 case 25: dmisc26 = value; break;
21339 4 case 26: dmisc27 = value; break;
21340 24 case 27: dmisc28 = value; break;
21341 case 28: dmisc28 = value; break;
21342 case 29: dmisc30 = value; break;
21343 case 30: dmisc31 = value; break;
21344 284 case 31: dmisc32 = value; break;
21345 }
21346 312 }
21347